Reputation: 43
I have 10 buttons in my UI, when I press one of them, I need to disable the rest; but here is the tricky part :
I have a background thread running under a while loop for real time update. the background thread update UI (the 10 buttons state and other stuff), the thing is once I click all buttons are disabled (good), but the refresh stops working on buttons (they stay disabled).
Why do I need to disable buttons knowing that they are going to change state after a second? because synchronising data is not very efficient, there is a 0.5s gap (to get data from DB and update UI) and in that 0.5s, a user can press some buttons that he is not supposed to press.
<Button Name="FirstGo" Width="60" Content="{StaticResource ButtonText_Go}" Click="FirstGoButtonClick" IsEnabled="{Binding First.JobLight,Converter={StaticResource JobLight2ButtonConv}}"/>
private void FirstGoButtonClick(object sender, RoutedEventArgs e)
{
FirstStop.IsEnabled = false;
SecondGo.IsEnabled = false;
SecondStop.IsEnabled = false;
//..... disabeling the other 6
//doing some stuff
ViewModel.RunFirstJob();
}
Upvotes: 0
Views: 692
Reputation: 1233
FirstStop.IsEnabled = false;
This code removes the binding, so, the succeeding update value to JobLight won't be recognized by the framework.
What you can do is to use SetCurrentValue.
Or put the collection of buttons into a Selector and handle the JobLight property when SelectionChanged happen.
Upvotes: 1