
Hello,
If you are setting the SelectedObject to an instance of CircularRange, then there isn't an easy way to see what properties on that are bound to your View Model and only display those. The PropertyGrid in general deals with the underlying values, not the bindings if there are any. The WinForms PropertyGrid Functionality Demo shows how you can get a BindingExpression from an IPropertyDataAccessor, which is effectively:
IPropertyDataAccessor propertyDataAccessor = ... ;
PropertyDescriptorDataAccessor propertyDescriptorDataAccessor = propertyDataAccessor as PropertyDescriptorDataAccessor;
if (propertyDescriptorDataAccessor == null) {
PropertyGridDataAccessorItem item = propertyDataAccessor as PropertyGridDataAccessorItem;
if (item != null)
propertyDescriptorDataAccessor = item.DataContext as PropertyDescriptorDataAccessor;
}
if (propertyDataAccessor != null && propertyDataAccessor.PropertyDescriptor != null) {
// Determine if the dependency property in the object is data bound
DependencyObject depObj = propertyDataAccessor.Target as DependencyObject;
DependencyPropertyDescriptor depProp = DependencyPropertyDescriptor.FromProperty(propertyDataAccessor.PropertyDescriptor);
if (depObj != null && depProp != null) {
BindingExpression bindingExpression = BindingOperations.GetBindingExpression(depObj, depProp.DependencyProperty);
// TODO: Check for View Model in DataItem property
}
}
You could perform this in the custom DataFilter to remove properties that are not bound to your View Model.
Otherwise, you could simply set SelectedObject to an instance of your View Model. That would display all the properites of your View Model, but they may not all be bound to the CircularRange.