How WPF uses WindowsFormsHost (that is, WinForm controls)

Source: Internet
Author: User

Original: How WPF uses WindowsFormsHost (that is, the WinForm control)

How to use:
1. First, we need to add two dynamic library DLLs to the references in the project (reference), one is. NET Library, the System.Windows.Forms other one is WindowsFormsIntegration ;
2, after adding two dynamic DLLs, you can find the WindowsFormsHost control in the control library.
3. Put this control into the form, and the corresponding code will be generated automatically in the Xmal code when you finish placing it:

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

4. Then, you need to add two lines of code at the beginning of the Xmal:
 

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

5. This allows you to place the required Windows Form control 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>

How WPF uses WindowsFormsHost (that is, WinForm controls)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.