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

WPF 精修篇 WPF嵌入Winfrom控件

时间:2019-12-21 00:24:35      阅读:105      评论:0      收藏:0      [点我收藏+]

标签:-o   嵌入   RoCE   src   cte   ffffff   idt   ESS   lang   

原文:WPF 精修篇 WPF嵌入Winfrom控件

先增加DLL 支持

技术图片

使用  WindowsFormsHost 来加载Forms的控件

引用命名空间

    xmlns:forms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
  1. <WindowsFormsHost Grid.Column="1">
  2. <forms:PropertyGrid x:Name="Property">
  3. </forms:PropertyGrid>
  4. </WindowsFormsHost>

效果

技术图片

代码 

  1. <Grid>
  2. <Grid.ColumnDefinitions>
  3. <ColumnDefinition Width="322*"/>
  4. <ColumnDefinition Width="195*"/>
  5. </Grid.ColumnDefinitions>
  6. <TextBlock x:Name="TextBlock" TextWrapping="Wrap" Text="TextBlock" />
  7. <WindowsFormsHost Grid.Column="1">
  8. <forms:PropertyGrid x:Name="Property">
  9. </forms:PropertyGrid>
  10. </WindowsFormsHost>
  11. </Grid>
  1. public MainWindow()
  2. {
  3. InitializeComponent();
  4. Property.SelectedObject = TextBlock;
  5. }

 

WPF 精修篇 WPF嵌入Winfrom控件

标签:-o   嵌入   RoCE   src   cte   ffffff   idt   ESS   lang   

原文地址:https://www.cnblogs.com/lonelyxmas/p/12075539.html

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