gpt4 book ai didi

wpf - DataTrigger.ExistActions 未针对绑定(bind)值 "null"触发

转载 作者:行者123 更新时间:2023-12-04 14:07:06 25 4
gpt4 key购买 nike

我有以下数据触发器,但退出操作没有触发。输入 Action 工作发现。我还尝试将 Binding 转换为 bool 值,以查看它是否与 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>

编辑:这里肯定发生了一些奇怪的事情,因为我也尝试过将 Storyboard排除在等式之外并只使用 Setters——现在什么都没有发生......







因此,代替此,我将发布整个 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 是一个 TreeView ,SelectedItem.Details 是一个实现 observablecollection 和 INotifyPropertyChanged 的​​类。我已经检查了调试器,此绑定(bind)正在正确更新,并且正在来回切换到我的实例值和空值。

最佳答案

我工作得很好!

         <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>

关于wpf - DataTrigger.ExistActions 未针对绑定(bind)值 "null"触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9214143/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com