Hello I have a problem with Binding and DataTrigger. So my code is:
<tog:HorizontalToggleSwitch Margin="0,10,15,0" HorizontalAlignment="Left" >
<tog:HorizontalToggleSwitch.Style>
<Style TargetType="{x:Type tog:HorizontalToggleSwitch}">
<Setter Property="IsChecked" Value="{Binding Staff.isSelfie, Mode=TwoWay}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=Admin,Path=IsChecked}" Value="True">
<Setter Property="IsChecked" Value="True" />
<Setter Property="IsEnabled" Value="False"/>
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=Admin,Path=IsChecked}" Value="False">
<Setter Property="IsChecked" Value="False" />
<Setter Property="IsEnabled" Value="True"/>
</DataTrigger>
</Style.Triggers>
</Style>
</tog:HorizontalToggleSwitch.Style>
</tog:HorizontalToggleSwitch>
As you can see I have a binding value Staff.isSelfie
at IsChecked Property and I change it within the Datatrigger. My problem is that I don't get the bool value of IsChecked at my variable Staff.isSelfie
. DataTrigger works because the switch change from off to on while I click at Admin Element which is a radiobutton. The code from Staff.isSelfie
is:
bool _isSelfie;
[DataMember]
public bool isSelfie
{
get
{
return _isSelfie;
}
set
{
if (_isSelfie != value)
{
_isSelfie = value;
OnPropertyChanged(nameof(isSelfie));
}
}
}
which implement INotifyPropertyChanged. The variable Staff.isSelfie
take his value from a bool in my database thats why I want to set it at the begin. How can I get the value true or false from DataTrigger to my variable Staff.isSelfie
? What is wrong? Thanks a lot.