How to use .NET Windows Control into the WPF Application

本文指导如何在WPF应用中整合Windows控件,包括创建WPF应用、引用必要的dll、拖放控件及XAML代码实现,演示了如何无缝利用已有Windows控件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 studio 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 would see the Windows Control there.

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

 

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

转自【http://www.a2zdotnet.com/View.aspx?Id=80#.Ub8hYpyvy3I】

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值