4
votes

I have the following datatrigger, but the exitactions is not firing. The enter actions work find. I have also tried convertering the Binding to a boolean to see if it had something to do with the null, but that didn't help either. What do I have wrong and why isn't my exitactions firing here?

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

EDIT: Something stange must be going on here because I've also tried taking the storyboard out of the equation and just using Setters -- and NOTHING is happening now...

So, in lieu of this, I'll post the entire TextBlock and maybe someone can point out what I'm missing

<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 is a treeview, and SelectedItem.Details is a class that implements observablecollection and INotifyPropertyChanged. I have checked with the debugger, this binding is updating properly and is toggling back and forth to my instance value and a null value.

1
btw, I've confirmed that the binding is indeed updating properly. The binding is changing back and forth to a null value as I'm expecting - but no exitactions :(mark

1 Answers

0
votes

Works fine by me!

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