Binding tip, only create observable collection once

I thought I’d share a really silly mistake I’ve just made. I have a list selector that is bound to an observable collection in my view model. However, when I was adding items to the collection they were not showing in the list. The mistake I had made was that upon refreshing the list I was using collection = new collection, this breaks the binding. So ensure you only create your target collection and if you want to refresh it then use collection.Clear().

Doh!

Phone development tip – disconnecting debug sessions?

Recently I’ve been asked to investigate a number of issues involving the Tombstone state. During the investigations I was using the ‘Tombstone upon deactivation’ and I was experiencing a number of lost connections between Visual Studio and the emulator/device. What I didn’t appreciate was these disconnections are almost always caused by a simple exception in the application. I.e. the app was failing because of a null exception which was causing the debugger to disconnect rather than break(). So my tips are;

  • If you get a disconnect, place breakpoints at positions *before* you expect to hit a problem area, do not rely on Visual Studio break-pointing and showing you the exception
  • Once you have a disconnect you will probably have to un-install the app from the emulator/device otherwise Visual Studio may not reconnect [Edit] I’ve also found that just directly launching the app from the emulator and then restarting the debug session also works. [Edit 2] Also engaging the lock-screen can also clear the problem. [Edit 3] Actually I think it’s just about waiting for a bit!
  • Test for Tombstone, it still exists!