Hi i am trying to write a datatrigger in which i have to clear a textbox content on checkbox checked.My Code is given below
It works as long as you dont type anything in the textbox.As soon as i type in the textbox the datatrigger fails to work.How can i solve this
<Window x:Class="CheckboxTextbox.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<Style x:Key="cbStyle" TargetType="{x:Type TextBox}">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=Chk,Path=IsChecked}" Value="True">
<Setter Property="Text" Value="{x:Null}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Window.Resources>
<StackPanel>
<CheckBox Name="Chk" Content="test"/>
<TextBox Style="{StaticResource cbStyle}">
</TextBox>
</StackPanel>
</Window>