WPF引用WinForm控件

原文: WPF引用WinForm控件

前言:WPF开发当中由于DataGrid控件实现业务未达到非常理想的效果,我决定使用WinForm中的DataGridView来实现业务。


     在XAML中加入以下命名空间:

xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
xmlns:wfi ="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"

     之后在将DataGridView加入XAMLGrid标签内:

复制代码
        <wfi:WindowsFormsHost>
            <wf:DataGridView x:Name="dgv">
                <wf:DataGridView.Columns>
                    <wf:DataGridViewTextBoxColumn  HeaderText="测试列" />
                </wf:DataGridView.Columns>
            </wf:DataGridView>
        </wfi:WindowsFormsHost>
复制代码

     注意使用时还是使用XAML语法编写,可以调出“属性”面板对DataGridView进行具体操作。

猜你喜欢

转载自www.cnblogs.com/lonelyxmas/p/12059732.html