如何使用prism框架mvvm动态显示数据网格中的列 [英] How to dynamically display columns in data grid using prism framework mvvm

查看:343
本文介绍了如何使用prism框架mvvm动态显示数据网格中的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想在DataGrid上的数据库中显示该表。任何人都可以告诉我应该在view,model和viewModel中编写什么代码,以便在datagrid中显示我的sql server的表。我需要在prism mvvm框架中实现这个东西。同时指导我完成相同的连接。

I simply want to display the table in my database on DataGrid. Can anybody tell me what code should be written in view,model and viewModel so as to display the table of my sql server in datagrid. I need this thing to be implemented in prism mvvm framework. Also guide me through the connectivity of the same.

推荐答案

WPF和Silverlight不能快乐地动态,你需要创建一个反映你的显示内容和移动的收藏数据表中的记录到要显示的集合中。



在xaml中,你需要定义每一列并将其映射到集合中的一个字段。



如果您确实需要动态视图,那么您将需要使用您打算使用的UI控件进行研究。例如,Telerik我已经看到了一些示例,其中Viewmodel构建了一组列,并且它们绑定到数据网格。
WPF and Silverlight don't do dynamic happily, you need to create a collect that reflects your display content and move the records from your datatable into the collection to be displayed.

In xaml you need to define each column and map it to a filed in the collection.

If you truly need a dynamic View then you are going to need to research it using the UI control you intend to use. Eg with Telerik I have seen examples where the Viewmodel buils up a collection of columns and they are bound to the datagrid.


这篇关于如何使用prism框架mvvm动态显示数据网格中的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆