So far my plan is to have an event "Item selected" which the property inspector listens to. The actual property inspector is just a ContentControl. When the object is selected the content property is set and the appropriate DataTemplate for editing the object is loaded.
In general I am trying to do this "MVVM" style. I guess you could use reflection instead of templating but I开发者_开发问答 only have a handful of types so far.
Has anyone implemented something similar?
Can you offer any advice or source code?
Basically, what you're looking for is a PropertyGrid... have a look at this : http://www.codeplex.com/wpg
If you want to do this MVVM style, then instead of having a ItemSelected event and using code to set the inspector's content, have a SelectedItem property in your viewmodel, and bind the inspector's Content to that property:
<ContentControl Content="{Binding SelectedItem}" />
How you update the SelectedItem will depend on the nature of your view and model. For example, if the items are displayed in a Selector control like a ListBox, then you would just two-way bind the Selector.SelectedItem to the viewmodel's SelectedItem.
Have a look at the WPF Inspector project. It's a spy utility like Snoop but it also includes a feature to debug triggers.
精彩评论