0

谁能告诉我这个模板可能有什么问题。扩展器仅在展开时动画,而不是折叠。

    <ControlTemplate x:Key="ExpanderExTemplate" TargetType="{x:Type Expander}" >
        <StackPanel Margin="0">
            <Border BorderThickness="1" >
                <Expander Name="expanderEx" Header="{TemplateBinding Header}" IsExpanded="{TemplateBinding IsExpanded}" BorderThickness="0">
                    <Border BorderThickness="0" >
                        <ContentPresenter x:Name="ExpandSite" Margin="5,5,5,5" >
                            <ContentPresenter.LayoutTransform>
                                <ScaleTransform x:Name="scaleTransform" ScaleX="1" ScaleY="1" />
                            </ContentPresenter.LayoutTransform>
                        </ContentPresenter>
                    </Border>
                    <Expander.Triggers>
                        <EventTrigger RoutedEvent="Expander.Expanded">
                            <EventTrigger.Actions>
                                <BeginStoryboard>
                                    <Storyboard >
                                        <DoubleAnimation From="0" To="1" Duration="0:0:0.25" 
                                                         Storyboard.TargetName="ExpandSite" 
                                                         Storyboard.TargetProperty="(FrameworkElement.LayoutTransform).(ScaleTransform.ScaleY)" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </EventTrigger.Actions>
                        </EventTrigger>
                        <EventTrigger RoutedEvent="Expander.Collapsed">
                            <EventTrigger.Actions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation From="1" To="0" Duration="0:0:0.25" 
                                                         Storyboard.TargetName="ExpandSite"
                                                         Storyboard.TargetProperty="(FrameworkElement.LayoutTransform).(ScaleTransform.ScaleY)" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </EventTrigger.Actions>
                        </EventTrigger>
                    </Expander.Triggers>
                </Expander>
            </Border>
        </StackPanel>
    </ControlTemplate>
4

0 回答 0