OpacityMask 无法与 WPF WindowsFormsHost 一起使用?

发布于 2024-09-27 06:30:37 字数 705 浏览 7 评论 0原文

我试图在通过 WindowsFormHost 对象托管的控件上放置圆角边框。看起来无论我为 OpacityMask 设置什么,它对渲染都没有影响。有什么我错过的吗?

这是我正在使用的 XAML 代码。子控件在运行时添加。我尝试过各种面膜组合,但没有一个对我有用。任何帮助将不胜感激。谢谢!

    <WindowsFormsHost Background="#FF2BBA62" Height="414" Width="516" Margin="176.5,223,309.5,92" Name="vcxHost1" UseLayoutRounding="False" ClipToBounds="True" >
        <WindowsFormsHost.OpacityMask>
            <VisualBrush>
                <VisualBrush.Visual>
                    <Rectangle Height="10" Width="100" Name="border1" />
                </VisualBrush.Visual>
            </VisualBrush>
        </WindowsFormsHost.OpacityMask>
    </WindowsFormsHost>

I'm trying to put a rounded border on a control which is hosted through a WindowsFormHost object. It seems like no matter what I set for OpacityMask, it has no effect on the rendering. Is there something I've missed?

Here is the XAML code I am using. The child control is added at run-time. I've tried various combinations of masks, none of which worked for me. Any help would be appreciated. Thanks!

    <WindowsFormsHost Background="#FF2BBA62" Height="414" Width="516" Margin="176.5,223,309.5,92" Name="vcxHost1" UseLayoutRounding="False" ClipToBounds="True" >
        <WindowsFormsHost.OpacityMask>
            <VisualBrush>
                <VisualBrush.Visual>
                    <Rectangle Height="10" Width="100" Name="border1" />
                </VisualBrush.Visual>
            </VisualBrush>
        </WindowsFormsHost.OpacityMask>
    </WindowsFormsHost>

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

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

发布评论

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

评论(1

寻梦旅人 2024-10-04 06:30:37

我怀疑它不起作用的原因与 z 索引不起作用的原因相同。来自链接的文档:“托管 Windows 窗体控件在单独的 HWND 中绘制,因此它始终绘制在 WPF 元素之上。”

请参阅有关布局限制的段落...
http://msdn.microsoft.com/en-us/library/ms744952.aspx

这也可能有帮助... http://msdn.microsoft .com/en-us/library/ms742522.aspx

I suspect it doesn't work for the same reason that the z-indexing doesn't work. From the linked doc: "A hosted Windows Forms control is drawn in a separate HWND, so it is always drawn on top of WPF elements."

See the paragraph on Layout Limitations ...
http://msdn.microsoft.com/en-us/library/ms744952.aspx

This may also be helpful ... http://msdn.microsoft.com/en-us/library/ms742522.aspx

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