views:

20

answers:

1

Hi,

I am looking for a solution for this scenario -

I need to implement a feature to allow user to add various controls to canvas(WPF, custom and third party ) and then select any one of them and modify some properties in property grid(changes needs to be reflected in UI).

I don't want to expose all the properties of any control only some of them(relevant to end user); apart from this there are some properties which will be common for all controls e.g. Title, Value(Value will be bound to some property of a control, say Text of TextBox and Content of Label) etc.

I am thinking of putting all the common proeprties at one place.

Things I am confused aout -

  1. How to create such base class, whether to use UserControl or Custom Control for this?

  2. How will the binding work between Control, base class proeprties and PropertyGrid?

  3. What type of object will I expose to property grid?

Any idea on what approch should be followed in this case, any kind of input will really be helpful.

A: 

Perhaps you should start from this book WPF Control Development Unleashed.

1) Custom control should be more appropriate.
2) For binding - You should learn more about TemplateBinding, RelativeSources binding etc.,
3) Your property can be either normal property or dependency property. Both, of them will be available for you in property grid to edit. If your exposed property is bindable, obviously, it should be dp. If you expose a property (means a property with public access specifier) it would be enough to get it available in the property grid.

HTH

Avatar