我无法找到在C#中使用Winform嵌入媒体元素的好方法。我在Winform中有一个PictureBox或Panel,应该在wpf中加载UserControl。这有可能吗?如果是的话,请给我一个小的伪代码。感谢
答案 0 :(得分:2)
您需要WinForms中的ElementHost控件来托管WPF控件
从该页面开始:
private void Form1_Load(object sender, EventArgs e)
{
// Create the ElementHost control for hosting the
// WPF UserControl.
ElementHost host = new ElementHost();
host.Dock = DockStyle.Fill;
// Create the WPF UserControl.
HostingWpfUserControlInWf.UserControl1 uc =
new HostingWpfUserControlInWf.UserControl1();
// Assign the WPF UserControl to the ElementHost control's
// Child property.
host.Child = uc;
// Add the ElementHost control to the form's
// collection of child controls.
this.Controls.Add(host);
}