Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

New Post: PropertyGrid validation for dynamic properties

$
0
0
I know the word 'dynamic' is probably overloaded by now. What I mean is the object that I am assigning to PropertyGrid.SelectedObject implements ICustomTypeProvider and based on one or more property values at runtime, other properties will be added dynamically. The only way I've been able to get the current PropertyGrid implementation to adjust to new (or removed) properties is to:

_propertyGrid.SelectedObject = null
_propertyGrid.SelectedObject = myObject
_propertyGrid.Update()

Now this seems to work fine and dandy, BUT I'm also trying to take advantage of .Net 4.5 validation, particularly INotifyDataErrorInfo interface.

By default Binding.ValidatesOnNotifyDataErrors is set to true in 4.5.

Now, when a property has been added to the SelectedObject, and the little switcheroo above is executed, I see PropertyItem.OnCoerceValueChanged get called, particularly the line:

Validation.MarkInvalid(be, errors[0]);

So I know the PropertyItem's binding has been manually marked with an validation error.

But I never see the validation visual show up.

If I manually invalidate a different property, i.e. blank out a required textbox and tab away, I see the same Validation.MarkInvalid code fire, but I do then see the nice red visual around the PropertyItem.

Any ideas? Thanks!

Viewing all articles
Browse latest Browse all 4964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>