如何在Silverlight 2中清除DataGrid? [英] How to Clear DataGrid in silverlight 2 ?

查看:56
本文介绍了如何在Silverlight 2中清除DataGrid?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Silverlight 2中清除数据网格中的所有项目,然后重新加载新项目.


有人知道怎么做吗?

I want to clear all items from my datagrid in silverlight 2 and reload it with new items.


Does anyone know how to do that?

推荐答案

尝试
DataGrid d;
d.ClearValue(DataGrid.ItemsSourceProperty)


它清除了网格,但是数据源也被删除了,所以这不是一个好方法.

DataSource1.Clear();

是这样做的好方法.
It clear the grid but the data source also remove so this is not a good way of doing that.

DataSource1.Clear();

is good way of doing that.


如果您的数据网格已绑定到集合,则可以尝试
dataGrid.ItemsSource = null.这将清除数据网格并取消收集.
if your datagrid is bound to a collection, you can try
dataGrid.ItemsSource = null. This will clear the datagrid and collection is nullified.


这篇关于如何在Silverlight 2中清除DataGrid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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