I\'ve implemented this property to hide and show an element:
private bool isWorking = false;
public bool IsWorking {
get {
return this.isWorking;
You probably want to have an async
Click event handler like this:
private async void Button_Click(object sender, RoutedEventArgs e)
{
viewModel.IsWorking = true;
await Task.Run(() =>
{
// do some long processing
});
viewModel.IsWorking = false;
}
Or an async method in your view model
public async Task DoSomeProcessing()
{
IsWorking = true;
await Task.Run(() =>
{
// do some long processing
});
IsWorking = false;
}
that is called from an async Click handler like
private async void Button_Click(object sender, RoutedEventArgs e)
{
await viewModel.DoSomeProcessing();
}