How to use. NET Windows Control into the WPF Application

Source: Internet
Author: User

Host the Windows Form Control into WPF Application

 

It is easy to place the Windows Control into the WPF Window. There are very extensive ranges of controls available in Windows, which can be used in WPF application after reading the article.

 

Steps:

1. Create the WPF Application in visual maxcompute 2008.

2. Make sure you have the reference of WindowsFormsIntegration. dll and System. Windows. Forms. dll.

3. Open the Window1.xaml in the designer.

4. Add the Windows Form namespace as follows

xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"

NOTE: If you want to any 3rd party control then add its reference to the project and add the namespace for the assembly.

 

5. Drag and drop the WindowsFormsHost control to Windows1.xaml Window.

6. Write the Xaml code inside the WindowsHost Element as followes

 

<My: WindowsFormsHost Name = "windowsFormsHost1"
Height = "62" VerticalAlignment = "Top">

<Wf: DateTimePicker Name = "dtpicker1"> </wf: DateTimePicker>

</My: WindowsFormsHost>

Compile and Run the WPF Application you wocould see the Windows Control there.

In the source code I user thee WindowsFormsHost, two contains
DateTimePicker and third one contain empty DataGrid.

 

Summary:If you have already made investigation in Windows Form control, you can use those in WPF without any issue.

From [http://www.a2zdotnet.com/View.aspx? Id = 80 #. Ub8hYpyvy3I]

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.