I have this problem in my code that when I write CurrentCanvas = null, and then initialize CurrentCanvas = ... then my UI doesn't have time to update this bindings, so I used some kind of kludge Task.Delay(10) to wait for the UI to update (although basically what I'm doing is also a kind of kludge, but not as bad as this), but I'd like to get rid of it, because using delays can be detrimental to the application, is there any way or workaround in my situation (this is the code from ViewModel)
[RelayCommand]
private async Task SelectCanvasAsync(ObservableCanvas selectedCanvas)
{
if (CurrentCanvas == selectedCanvas)
{
CurrentCanvas = null;
IsCanvasNull = true;
}
else
{
CurrentCanvas = null;
await Task.Delay(20); // KLUDGE!!!!! // UI Updates in milliseconds
CurrentCanvas = selectedCanvas;
IsCanvasNull = false;
}
}