WPF窗口中使用WinForm控件的一些限制

在WPF中使用WinForm的WebBrowser控件会遇到一些限制,如设置AllowsTransparency="True"会导致控件消失。《Programming Windows Presentation Foundation》指出,WindowsFormsHost不支持旋转、缩放或倾斜,只能设置不透明,且会覆盖其他WPF元素。同时,当鼠标在WindowsFormsHost上时,将无法接收WPF鼠标事件;当其有键盘焦点时,也无法接收键盘事件。此外,使用WinForm的定时器可能出现线程访问异常。WPF的frame控件展示HTML时也有类似不允许透明度的限制。
摘要由CSDN通过智能技术生成


在wpf中使用WinForm的控件有时候倒是很方便,特别是要使用ActiveX控件的时候必须把它封装成WinForm的控件才能使用,但使用的时候有诸多限制。这两天想在WPF窗口中使用一下WinForm的WebBrowser控件,但是一设置AllowsTransparency="True"属性,那个WebBrowser控件影都没有了,辛苦了两天去找原因,找方法,恍然间看到下面这段话。

抄一段《Programming Windows Presentation Foundation》上面的话,

WindowsFormsHost cannot be rotated, scaled, or skewed by a transform.

WindowsFormsHost supports only Opacity = 100% and can be contained only within other elements that are Opacity = 100%.

WindowsFormsHost will appear on top of other WPF elements in the same top-level window, although menus, ToolTips, and combo-box drop-downs are separate top-level windows and should work fine with WindowsFormsHost.

WindowsFormsHost does not respect the clipping region of its parent UIElement.

While the mouse is over the WindowsFormsHost, you won't receive WPF mouse events, and WPF's IsMouseOver property will return false

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值