开发者

EnterActions animations not stopping and ExitActions animations not starting

one of my company's applications displays pop ups by means of a content control centered on the screen, which is hidden until needed, and a radial gradient rectangle behind it to block the rest of the UI, plus it looks nice. I am trying to add an animation for when both the rectangle and the pop up are displayed, instead of just popping up. The enter animation works good, but the exit animation is never invoked when my pop up is closed, and the effects of the enter animation remain permanent.

My XAML is as follows:

<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Panel.ZIndex="999" DataContext="{Binding Source={x:Static popup:PopUpService.Instance}}" IsHitTestVisible="{Binding IsPopUpVisible}" Opacity="0">
        <Rectangle Fill="{DynamicResource RadialBlackToBlack}" />
        <ItemsControl Focusable="False" It开发者_Python百科emsSource="{Binding PopUps}">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <Grid IsItemsHost="True" />
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
        </ItemsControl>
        <Grid.Style>
            <Style TargetType="Grid">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsPopUpVisible, Source={x:Static popup:PopUpService.Instance}}" Value="True">
                        <DataTrigger.EnterActions>
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation Storyboard.TargetProperty="Opacity"
                                        To="100" Duration="0:0:1"/>

                                </Storyboard>
                            </BeginStoryboard>

                        </DataTrigger.EnterActions>
                        <DataTrigger.ExitActions>
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation Storyboard.TargetProperty="Opacity"
                                        To="0" Duration="0:0:1" />
                                </Storyboard>
                            </BeginStoryboard>
                        </DataTrigger.ExitActions>
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </Grid.Style>
    </Grid>

What is it that I'm doing wrong?

Thanks.


The opacity should animate to 1 not 100, this causes the problem. (The animation from 100 to 1 is not visible, and the last bit from 1 to 0 gets little animation time)

Maybe you also want to get rid of redundancy:

  1. Do not set properties twice or unnecessarily, drop the Duration on the Storyboards and all the HoldEnds, that is the default.
  2. Why is there an AutoReverse in the first SB?
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜