Create a popup with a ViewModel

Dec 27, 2012 at 3:57 PM

Is there a way of associating a ViewModel with a Popup - so that it can foe example, show the details of a selected row in a ListView ?


Dec 28, 2012 at 12:13 PM

Absolutely - and in fact you should aim to do this whenever possible, as it will make the popups easier to maintain. Here's how you do it.

First, create your viewmodel (use the template if that's easiest), add you list observable collection, maybe a notifying property for the selected object and so on.

Second, create a view which will be a popup - the way to do this is to create a UserControl for the visuals of your popup, then set the datacontext of your usercontrol to the viewmodel you've created.

If this doesn't make sense, then let me know - I could always send over a quick example project :) let me know how you get on. I'm keen to answer questions like this ASAP and make a page on the documentation for each of these common tasks.