DataBinding WPF Datagrid并在Windows窗体中显示数据 [英] DataBinding WPF Datagrid and displaying data in a Windows Form
本文介绍了DataBinding WPF Datagrid并在Windows窗体中显示数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个WPF用户控件,在该控件上有一个带有分组数据的datgrid.
我想在Windows窗体上使用此datagrid.我如何获取数据.
我正在使用数据集.
Hi,
I have a WPF User control on which i have a datgrid with grouped data.
I want to use this datagrid on a Windows Form. How i can get the data.
I am using Datasets.
推荐答案
将WFP库的引用添加到Windows应用程序.
使用工具箱中的System.Windows.Forms.Integration.ElementHost
,您可以在Windows窗体中嵌入WPF控件.
您可以在属性窗口中设置ElementHost
的Child属性,也可以按照以下步骤在程序上完成相同的操作.
Add a reference of your WFP library to your windows application.
UsingSystem.Windows.Forms.Integration.ElementHost
present in your toolbox you can embed a WPF control in windows form.
You can set the Child property of theElementHost
from the property window or same thing can be done programitacally as followng.
wpfElementHost.Child = new YoutUserControl();
为了设置数据源,您可以公开一个采用数据集的属性,也可以在WPF用户控件构造函数本身中传递该数据集.
For setting the the datasource you can expose a property which takes a dataset or you can pass the dataset in the WPF user control constructor itself.
我终于弄清楚了.
谢谢!!!!
I Finally figured this out.
thanks !!!
这篇关于DataBinding WPF Datagrid并在Windows窗体中显示数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文