[Turn] WPF added winform form

1, WPF add winform form - not my blog - CSDN blog .html ( https://blog.csdn.net/u011854789/article/details/54668859 )

 1.1、

  ZC: A hypothesis for the WPF project engineering, WinForm project for the B project.

  1. The original constructor rights winform program MainForm class into public
  2. Project output into a library (assuming that mainform.dll) ZC by the application: in B Engineering - Modify> "Applications" tab -> Project -> right property
  3. Add the necessary references ZC: A project to add a reference
  System.Windows.Forms
  WindowsFormsIntegration
  And mainform.dll
  1. Add a windowsformhost in a xaml wpf assumed name = wfh;
  2. Add a new class to be added form () in the MainWindow (such as the MainForm) Object

           MainForm mainform = new MainForm();
           wfh.Child = mainform;

  1. Exception caught, the subspace can not be top-level form, so the MainForm of TopLevel property to false to;
  2. Finally, run the program, OK!

2、

3、

4、

5、

6, wpf how to use WindowsFormsHost (ie winform controls) - qq_31971935's blog - CSDN blog .html ( https://blog.csdn.net/qq_31971935/article/details/72819736 )

Usage: 
  1, first of all, we need to reference (reference) to add two dynamic library dll project, is a .NET library System.Windows.Forms, the other one is WindowsFormsIntegration
  2, after you finish adding two dynamic dll, you can control library found WindowsFormsHost this control; 
  3, into the control this form, will automatically generate the code is placed after finished xmal code:

<Grid>
  <WindowsFormsHost Height="100" HorizontalAlignment="Left" Margin="36,29,0,0" Name="windowsFormsHost1" VerticalAlignment="Top" Width="200" />
</Grid>

  4, then we need to add two lines of code at the beginning of xmal: 

  xmlns:WinFormHost="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
  xmlns:WinFormControls="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"

  5, so that you can place Windows Form control needs of the under WindowsFormsHost. 

 <WindowsFormsHost Height="196" HorizontalAlignment="Left" Margin="104,65,0,0" Name="windowsFormsHost1" VerticalAlignment="Top" Width="286" >
  <WinFormControls:Button Text="WinformButton" Width="150"/>
 </WindowsFormsHost>

 

 

7、

 ZC: According to the above done to regenerate the project, as well as being given:

  

 7.1, engineering structure is such that: (WPF_FFME main engineering, DemoRealChart is joined to another project, WPF_FFME DemoRealChart be displayed inside the WinForm)

  

 7.2, I used EditPlus search "RealChart.cs", find "E: \ WPF_FFME \ WPF_FFME \ WPF_FFME.csproj" inside this line more reliable data:

   

 ZC: I modified them, the original is so above, modified so that:

    <Compile Include="..\DemoRealChart\RealChart.cs" />
    <Compile Include="..\DemoRealChart\RealChart.Designer.cs" />

  Then VS2017 will reload, and then things turned out:

  

  7.3, <EmbeddedResource Include = "RealChart.resx" /> using the same operation:

  <EmbeddedResource Include="..\DemoRealChart\RealChart.resx" />

 

 

 

8、

9、

 

Guess you like

Origin www.cnblogs.com/csskill/p/11388375.html