Question

What I do: I switch between scenes. Most of them have bindings to some viewmodels. This one has such a binding to an observableCollection with just 1 object. When I leave I want to clear the Collection to make sure that it loads a new one without showing old data or something while it's downloading.

I call the clear-function after backkeypress, so its deleted immediatelly:

void PageBackKeyPress(object sender, System.ComponentModel.CancelEventArgs e)
{
    App.ViewModel.JobDetail.Clear();
}

I tried it with JobDetail[0].Remove(); and JobDetail.RemoveAt(0); but still the same effect: It kinda freezes and then runs after 20 seconds or something. If I do it when leaving with the backkey it seems not to react to the backkey and then does all my backkey-hits at once (mostly closes the app). If I try to clear before loading I see a blank white screen and after the same 20seconds it shows the scene and THEN starts downloading (which takes some more seconds).

The ViewModel I try to load contains about 15 strings and 3 short string-lists (maximum 5 elements). With other ViewModels where I have 50 elements, each having about 10 strings and the same 3 string-lists, I don't have any problems to clear the list when leaving.

Any ideas?

I read that this happens a lot with VS2013 which I use. But it doesn't make any difference if I turn debug on or off, use other emulators or a real device. Same issue.

No correct solution

OTHER TIPS

Okay, the solution was simple:

void PageBackKeyPress(object sender, System.ComponentModel.CancelEventArgs e)
{
    DataContext = null;
    App.ViewModel.JobDetail.Clear(); // delete previous search
}

In other classes I didn't set DataContext to null but somehow it worked perfect. In this class deleting data that is bound was producing HUGE performance issues. Like I said about 20 seconds delay while normally everything was fine and fast.

Hope it helps someone else in future :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top