Observablecollection not updating

So it stands to reason that Observable Collection belongs in the view model. Microsoft’s own code generators encourage us to make this mistake.

When you add a reference to a WCF service returning a List, the proxy turns that into an Observable Collection.

Even Scott Hanselman made this mistake on stage at Mix ‘09 (skip to ).If we step through the debugger, though, we can verify that everything is wired up correctly. The logic is pretty straightforward - feel free to kick yourself like I did when I figured it out.Observable Collection raises a Collection Changed event whenever an item is added or removed - the Items Source binding will listen for this event and refresh appropriately.The Visibility property of the Items Control is bound to a custom IValue Converter that returns Visibility.Visible if the Items Source is non-empty, or Visibility. Additionally, we have a Text Box with a reverse IValue Converter In other words, if our Observable Collection is empty, we display the Text Box to notify the user there’s nothing there, otherwise we show the Items Control.

Search for observablecollection not updating:

observablecollection not updating-58observablecollection not updating-3observablecollection not updating-78

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “observablecollection not updating”

  1. Bob I am quiet, easy going, knowledgeable, understanding, honest, loving, caring, truthful and serious minded, My favorite colors are white, blue, orange and purple I like movies especially scary ones, bo…