我有一个数据网格,它显示一个绑定到一个DataSource
在时间约束上不断变化的表。DataSource
更新我的值时如何刷新数据网格的内容。
PS:我的DataSource
表中的值由监控系统更新。其表值会定期更新。
我应该在我的 EF 哪里添加我的 Observable Collection?
private IQueryable<MyTable> GetMyTablesQuery(TestDBEntities1 testDBEntities1 )
{
// definition of a Query to retrieve the info from my DB
System.Data.Objects.ObjectQuery<EF_demo1.MyTable> 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<EF_demo1.MyTable> 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();
}