2012-02-02 138 views
0

我有一个WinForms用户控件(工具栏),我想添加一个WPF用户控件,有没有办法做到这一点?在WPF用户控件上添加自定义Windows控件

像我想与其他WPF沿的WinForms用户控件(工具条)控制 上

我看到一对夫妇的样本,显示在WPF托管Windows窗体一个新的WPF用户控件(数据网格)控制。但那不是我想看到的。

+0

你想在WinForms应用程序中使用WPF控件,对吗? – sarvesh 2012-02-02 19:36:56

+0

“Windows .NET User Control”是指WinForms UserControl还是WPF UserControl? – 2012-02-02 19:52:08

+0

@Joe白色 - 赢取形式用户控制。 – 2012-02-02 20:30:47

回答

1

这很容易拉开。有被称为WindowsFormHost一个方便的小东西你需要做的就是在你的控件的XAML中声明它,巢您的形式控制在它的内部,像这样:

<UserControl> 
... 
<Grid> 
    <WindowsFormsHost> 
    <forms:MyFormsToolbarControl/> 
    </WindowsFormHost> 
</Grid> 

... 

WindowsFormHost生活正常WPF工具箱内如此它不应该很难找到。同时还有如何在这个位置产生代码相当于XAML的例子...

http://msdn.microsoft.com/en-us/library/ms751761.aspx