开发者

Dynamically binding to property of child controls

开发者 https://www.devze.com 2023-01-19 10:23 出处:网络
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 gener

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消