如何用数据填充GridView? [英] How can I populate the GridView with Data?

查看:87
本文介绍了如何用数据填充GridView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!,
我是WPF的新手,并且正在使用 MVVM Light Toolkit [ ] ,我正在尝试使用 Observable Collection 填充Telerik Gridview,有人可以帮我吗?

Hello All!,
I am a newbie to WPF and i am using MVVM Light Toolkit[], I am trying to populate a Telerik Gridview using Observable Collection, can any one help me out with this?

推荐答案

开始学习一些计时器此处 [
Go and Learn some timers here[^] here and create applicaion yourself


假设您有一个名为ViewModel的类具有单个属性的VM项目:
Lets say that you have a ViewModel class called VM with single property Items:
public class VM
{
public ObservableCollection<model> m_items=null;
public ObservableCollection<model> Items
{
   get{return m_items;}
   set{m_items=value; OnPropertyChanged(()=> Items);}
}
}</model></model>



然后,必须将Window类的DataContext属性设置为
的初始化值 VM:



Then you must set up DataContext property of Window class to initialized value of
VM:

Window1 wind=new Window1();
wind.DataContext= new VM();



比Xaml中的DataGrid集合属性ItemsSource到Items:



Than in Xaml in defenition of DataGrid set property ItemsSource to Items:

<....>


这篇关于如何用数据填充GridView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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