WPF引用WinForm控件

前言:WPF開發當中因爲DataGrid控件實現業務未達到很是理想的效果,我決定使用WinForm中的DataGridView來實現業務。測試


     在XAML中加入如下命名空間:spa

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

     以後在將DataGridView加入XAMLGrid標籤內:code

        <wfi:WindowsFormsHost>
            <wf:DataGridView x:Name="dgv">
                <wf:DataGridView.Columns>
                    <wf:DataGridViewTextBoxColumn  HeaderText="測試列" />
                </wf:DataGridView.Columns>
            </wf:DataGridView>
        </wfi:WindowsFormsHost>

     注意使用時仍是使用XAML語法編寫,能夠調出「屬性」面板對DataGridView進行具體操做。orm

相關文章
相關標籤/搜索