WPF中引入WindowsForms控制項的方法

2022-09-26 05:45:07 字數 809 閱讀 3651

環境:

[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控制項

x:name="listview1" margin="0,2,0,0" name="listview1"/>

>

step3:在cs**裡面操作windowsforms控制項

icon icon = new icon(@"driver.ico");

system.windows.forms.imagelist imagelist2 = new system.windows.forms.imageli程式設計客棧st();

imagelist2.images.add(icon);

listview1.smallimagelist = imagelist2;

WPF中引入外部資源

第一步 在vs中建立乙個wpf視窗程式 1 新建resources資料夾,右鍵點選專案,選擇新增,選擇新建資料夾,重新命名為resources 2 將所需的資源如,放在resources資料夾下面,雙擊resources.resx,選擇影象 新增資源 3 新增資源選擇現有檔案,然後選擇你需要資源 4...

WPF引入WindowsForms控制項示例

環境 1 windowsxp with sp3 2 vs2008 with sp1 正文 step1 在現有工程中引入windows forms 滑鼠右鍵 references 選擇 add reference net 標籤頁 加入 windowsformsintegration 和 system....

WPF 給UserControl引入多個資源

問題 為了方便資源的復用,我們通常會把資源單獨抽取為乙個資源檔案,供其他檔案引用。而使用者自定義控制項usercontrol中經常需要引入多個資源檔案。而在xaml中由於標籤usercontrol.resources內僅可以包含乙個content子元素。所以為了給usercontrol引入多個資源,...