Silverlight Bind to TextBlock from RIA Services

Posted by DaRKoN_ on Stack Overflow See other posts from Stack Overflow or by DaRKoN_
Published on 2009-09-01T05:57:47Z Indexed on 2010/04/03 20:03 UTC
Read the original article Hit count: 224

I've a TextBlock that looks like so:

<TextBlock Text="{Binding Name}" />

This is inside a <Canvas> with the DataContext set to MyClient which is in the ViewModel:

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();
}

Setting MyClient like the above does not raise the PropertyChanged event. As such the UI is never updated.

© Stack Overflow or respective owner

Related posts about Silverlight

Related posts about ria-services