使用 XamlFlair 制作 WPF 扩展器动画

问题描述 投票:0回答:2
wpf xaml animation expander
2个回答
1
投票

我摸索了两天,在发布问题后5分钟就找到了解决方案。

没有使用

xf:Animations.StartWith
,而是添加了这个:

<ContentPresenter.LayoutTransform>
    <ScaleTransform ScaleX="1" ScaleY="0" />
</ContentPresenter.LayoutTransform>

0
投票

如果你想实现膨胀和收缩的动画,可以将其写在Trigger中。

<ControlTemplate.Triggers>
    <Trigger Property="IsExpanded" Value="True">
        <Setter TargetName="ExpandSite" Property="xf:Animations.CombinedBinding" Value="True" />
        <Setter TargetName="ExpandSite" Property="xf:Animations.Primary" Value="{xf:Animate BasedOn={StaticResource ScaleFromTop}, Event=None, Duration=300, TransformOn=Layout}" />
        <Setter TargetName="ExpandSite" Property="xf:Animations.Secondary" Value="{xf:Animate BasedOn={StaticResource ScaleToTop}, Event=None, Duration=300, TransformOn=Layout}" />
    </Trigger>
    <Trigger Property="IsExpanded" Value="False">
        <Setter TargetName="ExpandSite" Property="xf:Animations.CombinedBinding" Value="False" />
        <Setter TargetName="ExpandSite" Property="xf:Animations.Primary" Value="{xf:Animate BasedOn={StaticResource ScaleFromBottom}, Event=None, Duration=300, TransformOn=Layout}" />
        <Setter TargetName="ExpandSite" Property="xf:Animations.Secondary" Value="{xf:Animate BasedOn={StaticResource ScaleToBottom}, Event=None, Duration=300, TransformOn=Layout}" />
    </Trigger>
</ControlTemplate.Triggers>
© www.soinside.com 2019 - 2024. All rights reserved.