在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.
While the WindowsFormsHost has keyboard focus, you won't receive WPF keyboar

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

被折叠的 条评论
为什么被折叠?



