开发者

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜