Question

I am building an application which has an ItemsControl, and my DataTemplate for this contains a ContentPresenter. I am binding this ContentPresenter to a UserControl property of my ViewModel. I would like to be able to allow the user to click a button on the UserControl which then shows that UserControl in a new popup window, and then when closed, it reverts back to being in the ItemsControl.

I can get this to show the UserControl in the popup window no problems, but have no idea how to revert it back to being in the ItemsControl.

Any suggestions for this approach would be greatly appreciated.

thanks

Était-ce utile?

La solution

Put simply you should not keep a UserControl (a UI element) inside your "ViewModel". Your ViewModels should hold the State of your UI and not the UI itself. Define two different UserControls for the two parts you want it in but this time Bind them to the same ViewModel properties.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top