Nick Kovalsky
Nick Kovalsky

Reputation: 6452

Xamarin not updating bindings when page is in background

I have a viewmodel bound to a page. The viewmodel is updating a property reacting to an event. When the page in is in background (covered by other pages) it doesn't update its UI, even when i execute the viewmodel code on UI thread:

Device.BeginInvokeOnMainThread(() =>
{
        MyProperty = false;
}

Observing this on Android at the moment. Solved but my own answer below.

Upvotes: 2

Views: 339

Answers (1)

Nick Kovalsky
Nick Kovalsky

Reputation: 6452

If i add a single line to this, it works, the page UI gets updated in background:

Device.BeginInvokeOnMainThread(async() =>
{
        await Task.Delay(10);
        MyProperty = false;
}

Upvotes: 1

Related Questions