码迷,mamicode.com
首页 > Windows程序 > 详细

【WPF】WPF中调用Winform

时间:2016-08-19 00:49:28      阅读:354      评论:0      收藏:0      [点我收藏+]

标签:

1、添加两个引用:WindowsFormsIntegration.dll(负责整合WPF和Windows)、System.Windows.Forms.
2、在 XAML文件中添加两个引用(粗体部分):

<Window x:Class="CrossBowDemo.MainWindow"
xmlns:wfi ="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
xmlns:wf ="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Hosting Windows Forms Control In WPF"
Height="300"
Width="650"
ResizeMode="NoResize"
Loaded="WindowLoadedHandler">
</Window>
3、在XAML添加控件:
<WindowsFormsHost Name="windowsFormsHost" Margin="0"  Background="#FF323E34">
       <wf:PictureBox Name="mainBox" Paint="PictureBox_Paint"></wf:PictureBox>
</WindowsFormsHost>

 

【WPF】WPF中调用Winform

标签:

原文地址:http://www.cnblogs.com/mqxs/p/5785890.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!