tags:

views:

226

answers:

4

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?

A: 

Basically, what you're looking for is a PropertyGrid... have a look at this : http://www.codeplex.com/wpg

Thomas Levesque
Yeah I just found that. Perhaps I should use reflection, although lots of my types are weakly modelled so depending on "type identifiers" I need to display different editors - reflection wont accomplish that. I guess my question is as much about the architecture of connecting the property inspector into my app
Schneider
You should probably use TypeDescriptor rather than reflection, since it is able to understand ComponentModel attributes (like default value, category, editor...)
Thomas Levesque
Just for anyone curious the "WPG" project appears to target .net 4
Schneider
A: 

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.

itowlson
This is a true property editor, so it is decoupled from any other view. It will be in its own tool window, so there will be no 'local' control to bind to such as ListBox. Currently planning on using Mediator pattern
Schneider
A viewmodel can span multiple windows -- just have the tool window bind to the same viewmodel instance as the "observed" window. Of course, if there are multiple "document" windows that the editor needs to be able to display items for, then that plan falls apart too \*grin\*. But yeah, Mediator sounds good, and more general.
itowlson
A: 

Hi im trying to make a fighting game. Kinda like Smash bros, well should I use Propert inspector or Spirte Properties. Or should I just order some kind of game maker CD?

John
A: 

Have a look at the WPF Inspector project. It's a spy utility like Snoop but it also includes a feature to debug triggers.

Greetings
Christian

Christian Moser