How can I change the Visibility of a TextBlock with a Trigger?
You need to specify the Type on which the visibility should be set
<Setter Property="FrameworkElement.Visibility" Value="Visible"/>
Try something like this:
<PasswordBox Name="pbxPassword" /><TextBox Text="{Binding Password, ElementName=pbxPassword, UpdateSourceTrigger=PropertyChanged}"> <TextBox.Style> <Style TargetType="TextBox"> <Setter Property="Visibility" Value="Hidden" /> <Style.Triggers> <DataTrigger Binding="{Binding IsChecked, ElementName=chbShowPassword}" Value="True"> <Setter Property="Visibility" Value="Visible" /> </DataTrigger> </Style.Triggers> </Style> </TextBox.Style></TextBox><CheckBox Name="chbShowPassword"> Show password</CheckBox>
Triggers of an element only support EventTrigger so you can't use property triggers (Trigger). Look FrameworkElement.Triggers Property.