WPF使用WinForm控件遇到的一些问题

WPF使用WinForm控件PIctureBox实现视频流




<wf:PictureBox x:Name="pbVideo" />


///


/// TestPictureBox.xaml 的交互逻辑
///

public partial class TestPictureBox : Window
{
public TestPictureBox()
{
InitializeComponent();
var handle = (this.pbVideo).Handle;
// 此处设置handle接收视频

}
}

测试过程中出现问题, 但在实际使用中发现PictureBox控件无法显示,查找资料发现是因为

AllowsTransparency="True"

导致WindowsFormsHost无法显示,去掉此属性又会导致窗体无法达到显示的效果,找到了WindowChrome


<Window.Resources>

</Window.Resources>


<wf:PictureBox x:Name="pbVideo" />


参考资料

WindowChrome官方介绍
WinformHost Control does not shown when windows AllowTransparency = true
WPF在WindowStyle=None时去掉顶部白条

posted @ 2021-05-12 14:28  the(seed)  阅读(526)  评论(0)    收藏  举报