Dynamically binding to property of child controls
Would it be possible to bind to Validation.HasErrors on any child con开发者_高级运维trol of a panel, without explicitly binding to every named control? Specifically i want to fire a trigger on a general style of a panel if any child control is in error state.
Thanks.
I would use an attached behavior that uses the LogicalTreeHelper
(or VisualTreeHelper
as a backup) to subscribe to the dependency property changed event of Validation.HasErrors
for each child element via DependencyPropertyDescriptor
. From there you would just update your own attached property (say, CompositeValidation.HasErrors
) and bind to that.
精彩评论