嗨,我正在尝试编写一个数据触发器,其中我必须在选中的复选框上清除文本框内容。我的代码如下所示
只要您不在文本框中键入任何内容,它就可以工作。只要我在文本框中键入数据触发器就无法工作。我该如何解决这个问题
<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>