0

I am currently working on a project that is using PRISM 4 + MVVM in a WPF 4 application.
I have been reading up on InteractionRequest and there seems to be little information on how to implement it so that the dialog is a stylable user control and has textbox and other controls in it.
All the samples I find are just dialog windows with text in them.

What I am looking to do is have a listview that when a user selects an item it opens a dialog box where they can edit the details and either save or cancel.

Is this the correct approach with WPF? Should I be doing something other than InteractionRequest?
I generally do web applications so WPF is a bit new to me.

Any assistance would be greatly appreciated.

Thanks!

Hakan Fıstık
  • 16,800
  • 14
  • 110
  • 131
Juan
  • 1,144
  • 1
  • 11
  • 16

2 Answers2

2

I'm using both a dialog service and interaction requests.

A dialog service is better for common dialogs that must be displayed throughout your application which have the same look and feel. For example, OpenFileDialog, Color Choosers, Printing, Error Messages, etc.

Interaction requests can be better for simple user interactions which are specific to a certain view. For example, let's pretend that a view has a button which is bound to a command in the view model. That command allows the user to pick between options A,B,C and then performs some function with that choice. The ViewModel may start an InteractionRequest that it wants the user to pick from A,B,C. The View can handle that event and provide a simple template which describes how to display those options A,B,C to the user. Therefore you maintain separation of UI & business logic. In this case, it seems better to implement this custom interaction from within the View code because it is simple and specific to this view.

Alan
  • 7,875
  • 1
  • 28
  • 48
  • Hi Alan. In the case you'd create an interaction request to choose between many options (in my case, I created a user control with a listview and a confirm button), would you implement a new type for InteractionRequest or you'd use the confirmation/notification? – willmichels Mar 11 '13 at 16:59
  • @willmichels To be honest, I didn't like the way Microsoft had implemented that, so I re-implemented my own version (taking a look at their source) and made IntertactionRequest where T : Interaction. My Interaction class had object Content and a Finish() method.. but I think you can use the standard Confirmation (assuming you want a ok/cancel semantics).. again.. I didn't like the way it felt so I made an InteractionRequest take my own custom "Interaction" and then Confirmation : Interaction, with Accept(), Reject(), and a Result property. so I may not be the best person to ask – Alan Mar 11 '13 at 20:36
0

i simply use a dialog service for this kind of work.

in your viewmodel you just have to call

  var result = this.uiDialogService.ShowDialog("Dialogwindow title goes here, eg Edit Details", detailViewmodel);

thats all :)

EDIT:

you can style your UserControl like you want

<DataTemplate DataType="{x:Type local:DetailViewModel}" >
    <view:DetailsView/>
</DataTemplate>
Community
  • 1
  • 1
blindmeis
  • 22,175
  • 7
  • 55
  • 74
  • Thanks. Looks like that opens a Window, can it also be a user control? I would like something that I can style so it doesnt look like the standard window control. – Juan Oct 30 '12 at 13:36