C# 如何在windows窗体的WPF中添加Mediaelement
我找不到在C#中的Winform中嵌入mediaelement的好方法。我有一个Winform中的PictureBox或面板,应该在wpf中加载一个UserControl。这可能吗?如果是,请给我一点伪代码。谢谢您需要WinForms中的控件来承载WPF控件 从该页:C# 如何在windows窗体的WPF中添加Mediaelement,c#,wpf,winforms,user-controls,mediaelement,C#,Wpf,Winforms,User Controls,Mediaelement,我找不到在C#中的Winform中嵌入mediaelement的好方法。我有一个Winform中的PictureBox或面板,应该在wpf中加载一个UserControl。这可能吗?如果是,请给我一点伪代码。谢谢您需要WinForms中的控件来承载WPF控件 从该页: private void Form1_Load(object sender, EventArgs e) { // Create the ElementHost control for hosting the //
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);
}