HwndSource不显示Adorner层

发布于 2024-08-03 01:33:24 字数 95 浏览 3 评论 0原文

当我在 HwndSource 中托管使用​​装饰器(文本框的错误边框)的 WPF 控件时,不会显示装饰器。看起来装饰层不存在。为什么会这样?我能做什么呢?这是一个已知的错误吗?

When I host WPF controls that use adorners (the error border of the textbox) in a HwndSource the adorners are not shown. It seems that the adorner layer is not there. Why is that so and what can I do against it? Is this a known bug?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尹雨沫 2024-08-10 01:33:24

AdornerLayer 通常是 Window 类的默认模板的一部分。

如果您要在窗口以外的其他对象中自定义窗口模板或主机控件;您必须自己创建 AdornerLayer。

这可以通过将 WPF 控件包装在 System.Windows.Documents.AdornerDecorator 中来完成:

hwndSource.RootVisual = new AdornerDecorator { Child = yourTextBox };

The AdornerLayer is usually part of the default template of the Window class.

If you are customizing the Window template or host controls in something else than a Window; you'll have to create the AdornerLayer yourself.

This can be done by wrapping your WPF controls inside a System.Windows.Documents.AdornerDecorator:

hwndSource.RootVisual = new AdornerDecorator { Child = yourTextBox };
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文