xceedsoftware / wpftoolkit

All the controls missing in WPF. Over 1 million downloads.
Other
3.91k stars 878 forks source link

PropertyGrid how to add a custom property with PropertyDefinition having bool (checkBox) type #1721

Open salmana66 opened 2 years ago

salmana66 commented 2 years ago

Hi,

I've been using a propertyGrid and i want to add a new property to keep the height and width ratio of any selected item. Anyone please help me how i can add a new property having type checkBox (bool).

i'm trying this var propertyDefinition = new PropertyDefinition() { Category = "Layout", DisplayName = "KeepRatio", TargetProperties = new string[] { "KeepRatio" }, HasAttribute = typeof(Boolean) }; propertyGrid1.PropertyDefinitions.Add(propertyDefinition);

Really appreciate your help!

XceedBoucherS commented 2 years ago

Hi,

The PropertyGrid will display the properties of its SelectedObject. If the SelectedObject do not have a "KeepRatio" property, the PropertyGrid won't show it. Are you trying to add a PropertyItem to the PropertyGrid when the SelectedObject does not have a "KeepRatio" property ? If so, this is not the purpose of the PropertyGrid. Adding a new PropertyItem wouldn't bind it with the SelectedObject.

Thank you