【问题标题】:HwndSource does not display the Adorner layerHwndSource 不显示 Adorner 层
【发布时间】:2010-11-22 15:23:31
【问题描述】:

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

【问题讨论】:

    标签: wpf interop adorner adornerlayer adornerdecorator


    【解决方案1】:

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

    如果您正在自定义 Window 模板或宿主控件,而不是 Window;您必须自己创建 AdornerLayer。

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

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

    【讨论】:

    • 谢谢丹尼尔,我永远不会发现自己
    猜你喜欢
    • 1970-01-01
    • 2018-10-02
    • 2017-09-24
    • 1970-01-01
    • 2011-05-31
    • 2015-11-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多