欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

WPF中引入WindowsForms控件的方法

 更新時間:2016年07月05日 11:24:29   作者:kagula  
這篇文章主要介紹了WPF中引入WindowsForms控件的方法,結合實例形式分析了在WPF中調用Windows Forms控件的具體步驟與相關實現技巧,需要的朋友可以參考下

本文實例講述了WPF中引入WindowsForms控件的方法。分享給大家供大家參考,具體如下:

環(huán)境:

[1]WindowsXP with SP3

[2]VS2008 with SP1

正文:

Step1:在現有工程中引入Windows Forms

鼠標右鍵[References]->選擇[Add Reference]->[.NET]標簽頁

加入[WindowsFormsIntegration]和[System.Windows.Forms]兩項

Step2:在XAML文件里加入

[S2-1]加入namespace引用:

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

[S2-2]加入Windows Forms控件

<wfi:WindowsFormsHost Name="winFormsContainer" Grid.Row="2" Margin="0,5,0,0">
 <wf:ListView x:Name="listView1" Margin="0,2,0,0" Name="listView1"/>
</wfi:WindowsFormsHost>

Step3:在CS代碼里面操作WindowsForms控件

Icon icon = new Icon(@"driver.ico");
System.Windows.Forms.ImageList imageList2 = new System.Windows.Forms.ImageList();
imageList2.Images.Add(icon);
listView1.SmallImageList = imageList2;

更多關于C#相關內容感興趣的讀者可查看本站專題:《C#窗體操作技巧匯總》、《C#常見控件用法教程》、《WinForm控件用法總結》、《C#程序設計之線程使用技巧總結》、《C#操作Excel技巧總結》、《C#中XML文件操作技巧匯總》、《C#數據結構與算法教程》、《C#數組操作技巧總結》及《C#面向對象程序設計入門教程

希望本文所述對大家C#程序設計有所幫助。

相關文章

最新評論