我有一个数据网格,显示一个绑定到DataSource的表,该数据源不断更改时间约束.
如何在更新myDataSource值时刷新数据网格的内容.
P.S:我的DataSource表中的值由监控系统更新.其表值定期更新.
我应该在EF中添加我的Observable Collection?
private IQueryable GetMyTablesQuery(TestDBEntities1 testDBEntities1 )
{
// definition of a Query to retrieve the info from my DB
System.Data.Objects.ObjectQuery myTablesQuery = testDBEntities1.MyTables;
// Returns an ObjectQuery.
return myTablesQuery ;
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
// A New entity container is created that uses the object context
var testDBEntities1 = new EF_demo1.HMDBEntities1();
// Load data into MyTables.
var myTablesViewSource= ((System.Windows.Data.CollectionViewSource)(this.FindResource("myTablesViewSource")));
// the query which is defined above is executed here. It grabs all the information from the entity container
IQueryable myTablesQuery = this.GetMyTablesQuery(testDBEntities1 );
//The query result is binded to the source of the myTablesViewSource, which inturn binds back to the list.
myTablesViewSource.Source = myTablesQuery .ToList();
}