Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3622738
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:17:48+00:00 2026-05-18T23:17:48+00:00

Where to start? Question is about two different ways to achieve the same thing,

  • 0

Where to start? Question is about two different ways to achieve the same thing, and both smell to me, so I need somebody to tell me whether there is a better way. So, we have a screen that displays data in data grid. When user clicks an icon in data grid, a modal pop up window (from Prism) is displayed. This can be done two ways, that I know of, working with SL for 2 weeks.
To give some more background, we use MVVM pattern, and we have a ViewModelLocator.

Button in datagrid per each row

<Button Width="16" Name="cmdEdit" Height="16" Margin="10,0,0,0" Style="{StaticResource ImageButtonStyle}" Click="cmdEdit_Click" CommandParameter="{Binding}">
         <Button.Content>
             <Image  Source="/Test.Application.Bid;component/Images/edit.png"/>
          </Button.Content>
</Button>

First way, handle click from code behind:

var p = new PopupChildWindowAction();
 var vml = new ViewModelLocator();
 var viewModel = vml["BidAgentEditView"] as BidAgentEditViewModel;
 var view = new BidAgentEditView();
 view.DataContext = viewModel;
 viewModel.BidAgent = ((Button) e.OriginalSource).CommandParameter as BidAgentDto;
 p.ChildWindow = view;
 p.ChildWindow.Show();

Second way is to use InteractionRequestTriggers in xaml, and commands on view model like this

button in data grid

 <Button Width="16" Height="16" Margin="10,0,0,0" Style="{StaticResource ImageButtonStyle}" 
         prism:Click.Command="{Binding Source={StaticResource cc}, Path=DataContext.EditBidAgentCommand}" 
         prism:Click.CommandParameter="{Binding}">

in viewmodel ctor

this._editBidAgentRequest = new InteractionRequest<BidAgentEditViewModel>();

EditBidAgentCommand = new DelegateCommand<BidAgentDto>(editBidAgent, canEditBidAgent);

and handler for command

 private void editBidAgent(BidAgentDto bidAgent)
 {
     _editBidAgentRequest.Raise(newBidAgentEditViewModel(bidAgent,_bidAgentDataService));
  }

So view invokes command on the view model that turns around and raises interaction request that is than handled by the view and it pops up the child window. Maybe I don’t understand MVVM, but this seems to be overly complicated way to handle user interaction. Plus that fact that I have something calles “Interaction” on view model makes me feel dirty. What do you think, is there a better way to do this without having to declare these interaction requests on the view model, something that is done completely in xaml, without having to handle this in view model?

From code behind first to grasp what is going on:

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T23:17:49+00:00Added an answer on May 18, 2026 at 11:17 pm

    As you probably know, Prism proposes interaction requests for this kind of scenario. Remember, that the VM must handle the business logic part of the view. Ordering to show a popup when an action occurs is part of the VMs responsibilities.

    Additionally, you keep your View clean and without any codebehind (which is otherwise almost untestable), plus you are using the benefits of Silverlight to your advantage.

    Summing up, interaction requests seem pretty neat to me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project that adds elements to an AutoCad drawing. I noticed that
I have a new web app that is packaged as a WAR as part
I know its probably possible, but is it practical and doable to try and
I know its probably possible, but is it practical and doable to try and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.