我有以下数据触发器,但是没有触发exitactions。输入操作工作找到。我也尝试将Binding转换为布尔值以查看它是否与null有关,但这也无济于事。我有什么不对,为什么我的出境活动不在这里解雇?
<DataTrigger Binding="{Binding }" Value="{x:Null}">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" To=".5" From="0" Duration="0:0:1"></DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="0" From=".5" Duration="0:0:1"></DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</DataTrigger.ExitActions>
</DataTrigger>
编辑:必须要在这里做一些事情,因为我也尝试将故事板排除在外,只使用Setter - 现在正在发生的事情......
所以,代替这一点,我会发布整个TextBlock,也许有人可以指出我缺少的东西
<Grid DataContext="{Binding ElementName=ConfigTree, Path=SelectedItem.Details}">
<TextBlock HorizontalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center" Padding="10" VerticalAlignment="Center" FontWeight="Bold" FontSize="14" Opacity="0">
Select a configuration on the right to modify its selected columns
<TextBlock.Style>
<Style TargetType="TextBlock" BasedOn="{StaticResource {x:Type TextBlock}}">
<Style.Triggers>
<DataTrigger Binding="{Binding }" Value="{x:Null}">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard Duration="0:0:1">
<DoubleAnimation Storyboard.TargetProperty="Opacity" To=".5" From="0" Duration="0:0:1"></DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="0" From=".5" Duration="0:0:1"></DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
ConfigTree是一个树视图,SelectedItem.Details是一个实现observablecollection和INotifyPropertyChanged的类。我已经检查过调试器,这个绑定正在正确更新,并且来回切换到我的实例值和空值。
答案 0 :(得分:0)
我工作得很好!
<CheckBox x:Name="MyCheckBox"
IsThreeState="True"
Content="I am Tristate! Check Me"/>
<TextBox x:Name="MyTextBlock"
Background="Cyan"
Text="1234567890">
<TextBox.Style>
<Style TargetType="{x:Type TextBox}">
<Style.Triggers>
<DataTrigger
Binding="{Binding ElementName=MyCheckBox,
Path=IsChecked}"
Value="{x:Null}">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="Opacity"
To=".5" From="0"
Duration="0:0:1">
</DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="Opacity"
To="0" From="0.5"
Duration="0:0:1">
</DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>