DataBindings lost during App-Switching/Tombstoning in WP7

120 views Asked by At

I've set up a viewmodel to bind a listcontrol to an ObservableCollection in my program. A UI control on the page adds and deletes objects to the collection, which works fine as the list is automatically updated.

After App-Switching and returning to the app, the buttons adds the objects, but the bindings seem to be lost. Any idea how I can maintain this even after returning? I don't really see the need to rebind the object (after defining it in XAML). Is there any way to foolproof this pattern, and ensure the bindings aren't lost upon returning to the app?

The XAML looks like this, but it's inside a UserControl - forgot to mention that

ItemsControl x:Name="PartyCollection" ItemTemplate="{StaticResource PartyCollectiontemplate}" ItemsSource="{Binding RoomParty, Source={StaticResource FormControlVM}}"

the codebehind looks like this

public class FormControlVM : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;
    public ObservableCollection<Party> RoomParty
    {
        get
        {
            return App.appData.currentChoices.roomParty;
        }
        set
        {
            App.appData.currentChoices.roomParty = value;
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs("RoomParty"));
        }
    }
}
0

There are 0 answers