0

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?

3 Answers 3

1

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

Sign up to request clarification or add additional context in comments.

3 Comments

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
You should probably use TypeDescriptor rather than reflection, since it is able to understand ComponentModel attributes (like default value, category, editor...)
Just for anyone curious the "WPG" project appears to target .net 4
1

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.

2 Comments

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
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.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.