How to call the winform control in WPF

Source: Internet
Author: User

The function is implemented in three steps:
1. Add two references: windowsformsintegration. dll (responsible for integrating WPF and Windows), system. Windows. forms.
2. Add two references to the XAML file (in bold ):

3. Implement the control you want to add in the XAML coding area:

In the original article, the datagridview control is added:

 

<WFI: windowsformshost>
<! -- Set some properties on Windows Forms control in XAML -->
<WF: datagridview X: Name = "datagridview" dock = "fill" selectionmode = "fullrowselect"/>
</WFI: windowsformshost>

:

I added the numericupdown control:

<Grid Height = "0" margin = "146,0, 0,116 "minheight =" 20 "minwidth =" 20 "name =" grid1 "verticalignment =" bottom "horizontalalignment =" Left "width =" 50 ">
<WFI: windowsformshost>
<WF: numericupdown X: Name = "nupcounter" Maximum = "100"> </WF: numericupdown>
</WFI: windowsformshost>
</GRID>

 

<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>
Related Article

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.