且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

WPF 验证错误文本溢出

更新时间:2023-02-26 13:36:02

这是设计使然.Validation.ErrorTemplate 将显示在装饰层上.装饰层中的元素呈现在其余视觉元素之上,并且在布局系统测量和排列控件时不会考​​虑它们.

This is by design. The Validation.ErrorTemplate will be displayed on the adorner layer. Elements in the adorner layer are rendered on top of the rest of the visual elements and they will not be considered when the layout system is measuring and arranging the controls.

来自 MSDN:https://msdn.microsoft.com/en-us/library/system.windows.documents.adornerlayer(v=vs.110).aspx

放置在装饰层中的任何内容都将呈现在您设置的其余任何样式之上.换句话说,装饰器总是在视觉上位于顶部,不能使用 z-order 覆盖.

Anything placed in the adorner layer is rendered on top of the rest of any styles you have set. In other words, adorners are always visually on top and cannot be overridden using z-order.