WPF 中的 WindowsForm 图片框
我发现这个很酷的应用程序可以让您与家庭网络建立网络摄像头连接,但它使用 PictureBox 来显示网络摄像头流。
我有一个 PictureBox 可在 WPF 中工作,但它似乎无法调整大小。
示例: https://i.sstatic.net/mpEsN.png
我做错了什么?
这是我当前的 XAML 代码:
<Grid>
<wfi:WindowsFormsHost>
<winForms:PictureBox x:Name="pictureBoxLoading">
</winForms:PictureBox>
</wfi:WindowsFormsHost>
</Grid>
I found this cool application which lets you have a webcam connection with your home network but it uses a PictureBox to show the webcam stream.
I got a PictureBox to work in WPF, but it doesn't seem to resize.
Example: https://i.sstatic.net/mpEsN.png
What am I doing wrong?
This is my current XAML Code:
<Grid>
<wfi:WindowsFormsHost>
<winForms:PictureBox x:Name="pictureBoxLoading">
</winForms:PictureBox>
</wfi:WindowsFormsHost>
</Grid>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设在您的代码中您没有使用本机 WPF 图像控件。任何本机 WPF 控件在包含在网格或视图框中时都可以自动调整大小。
由于您使用的是 Windows 窗体控件,因此您必须自己处理大小调整,因为WindowsFormsHost 仅托管 Windows 窗体控件,而不是像普通 WPF 控件那样与其交互。
I assume in your code you're not using native WPF Image control. Any native WPF control can automatically resize when included in a grid or in a Viewbox.
Because you're using Windows Forms control, you have to handle the resize yourself, because WindowsFormsHost only host Windows Forms control, NOT interacting with it as a normal WPF control.