I am trying to create a situation where one or none of a grouping of two ToggleButton
s can be on at any time. The problem that I have is if I change the state of the backing variable the UI state does not update.
I do have INotifyPropertyChanged
implemented.
I've created my ToggleButton
s like this:
<ToggleButton IsChecked="{Binding Path=IsPermanentFailureState, Mode=TwoWay}"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center">
<TextBlock TextWrapping="Wrap"
TextAlignment="Center">Permanent Failure</TextBlock>
</ToggleButton>
<ToggleButton IsChecked="{Binding Path=IsTransitoryFailureState, Mode=TwoWay}"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center">
<TextBlock TextWrapping="Wrap"
TextAlignment="Center">Temporary Failure</TextBlock>
</ToggleButton>
This is my backing properties (I am using the MVVM pattern, the other bindings work, IE clicking on the ToggleButton
does enter these property settings. When I'm changing the state via code, the Toggle Buttons don't change visual state. IE I am setting the backing property to false, but the button stays checked.
public bool? IsPermanentFailureState
{
get { return isPermFailure; }
set
{
if (isPermFailure != value.Value)
{
NotifyPropertyChanged("IsPermanentFailureState");
}
isPermFailure = value.Value;
if (isPermFailure) IsTransitoryFailureState = false;
}
}
public bool? IsTransitoryFailureState
{
get { return isTransitoryFailureState; }
set
{
if (isTransitoryFailureState != value.Value)
{
NotifyPropertyChanged("IsTransitoryFailureState");
}
isTransitoryFailureState = value.Value;
if (isTransitoryFailureState) IsPermanentFailureState = false;
}
}