【发布时间】:2014-03-11 00:24:00
【问题描述】:
当我将 MySql 数据库的实体数据模型添加到 WPF 应用程序和为父表和子表创建的 CollectionViewSource 时,例如:
<CollectionViewSource x:Key="topicmainViewSource" d:DesignSource="{d:DesignInstance {x:Type dbMRCPe:topicmain}, CreateList=True}"/>
<CollectionViewSource x:Key="articlesRelatedViewSource" Source="{Binding topicsublev1, Source={StaticResource topicmainViewSource}}"/>
并为网格创建 DataContext 并绑定到 radgridviews 之类的
<Grid Name="maingrid" DataContext="{StaticResource topicmainViewSource}">
<telerik:RadGridView x:Name="TopicMaingridview" DataMember="idTopicMain" ItemsSource="{Binding}" />
<telerik:RadGridView x:Name="articlesRelatedRadGridView" ItemsSource="{Binding Source={StaticResource articlesRelatedViewSource}}" />
</Grid>
这是在cs中加载数据的代码
dbMRCPe.dbmrcpnephrologyEntities ctx = new dbMRCPe.dbmrcpnephrologyEntities();
private void Window_Loaded(object sender, RoutedEventArgs e)
{
ctx = new dbMRCPe.dbmrcpnephrologyEntities();
System.Windows.Data.CollectionViewSource topicmainViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("topicmainViewSource")));
// Load data by setting the CollectionViewSource.Source property:
topicmainViewSource.Source = ctx.topicmains;
}
问题:如果用户在运行时将数据添加到gridview,如果使用的引用按钮没有在两个网格之间失去关系,如何在运行时将数据重新加载到其他用户界面?
【问题讨论】:
标签: c# mysql wpf gridview entity-framework-5