WPF中引入WindowsForms控件的方法
本文實例講述了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#程序設計有所幫助。
相關文章
基于NET?Core?的Nuget包制作、發(fā)布和運用流程解析(完整過程)
這篇文章主要介紹了基于NET?Core?的Nuget包制作、發(fā)布和運用流程,本文通過圖文并茂的形式給大家介紹了Nuget包制作過程,感興趣的朋友跟隨小編一起看看吧2022-02-02