简体   繁体   中英

dynamic popup window mvvm light wpf

I have a problem with my mvvm project:

In my project i have a listview that contains a list of different kinds of objects, and i want to make a pop up window that will show additional info about each object. The popup shows up when you click on a item in the listView..

I have two problems with this,

  1. how do i send the selected item from the view model of the list to the popup?
  2. how do i dynamically change the style of the content inside the popup by the type of item that was sent to it.

Thanks...

You should bind the DataContext property of the popup to the selected item property of the viewmodel.

Also, in the popup definition, you can use DataTemplates, and its DataType property. In the popup resources, you can define a DataTemplate for each type you want to display, and configure the DataType to this type. In the content of the popup, a simple ContentControl with the Content bound to the DataContext itself will to the trick.

Hope it answered your problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM