我有一个看起来像这样的 TextBlock:
<TextBlock Text="{Binding Name}" />
这是<Canvas>
在 ViewModel 中的 DataContext 设置为 MyClient 的内部:
public Client MyClient { get; private set; } // This is a RIA Entity, hence supports INotifyPropertyChanged
public ViewModel() {
MyClient = new Client();
LoadOperation<Client> loadClient = RiaContext.Load<Client>(RiaContext.GetClientsQuery());
loadClient.Completed += new EventHandler(loadClient_Completed);
}
void loadClient_Completed(object sender, EventArgs e) {
MyClient = DB.Clients.Single();
}
像上面这样设置 MyClient 不会引发 PropertyChanged 事件。因此,UI 永远不会更新。