在我的主页面上,我有一个扩展器,它有一个动画的事件触发器,如下所示:
<StackPanel.Triggers>
<EventTrigger RoutedEvent="Expander.Expanded" SourceName="expander">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation From="0" To="1.2" Duration="0:0:0.35" Storyboard.TargetName="content1" Storyboard.TargetProperty="(FrameworkElement.LayoutTransform).(ScaleTransform.ScaleX)" AutoReverse="False" />
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</StackPanel.Triggers>
<Expander x:Name="expander" ExpandDirection="Right" OpacityMask="#6C806969" Background="#FF807171" >
<Grid x:Name="content1" Background="#FF807171" Width="378">
......user control inside here
<Grid.LayoutTransform>
<ScaleTransform ScaleX="0" ScaleY="1"/>
</Grid.LayoutTransform>
</Grid>
</Expander>
这只是将膨胀机缓慢滑出。但是在一个扩展器头部区域内,我有另一个扩展器(一个是垂直设置,另一个是水平设置。
水平扩展器是UserControl的一部分。当我扩展这个扩展器时,它会从主窗口发射垂直扩展器。
<UserControl x:Class="WpfApplication4.AppPages.AddPost"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="464" d:DesignWidth="416">
<Expander Header="expander1" Height="441" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top">
..... some content
</Expander>
反正有没有阻止这种情况发生?
答案 0 :(得分:1)
这是我评论中建议的示例代码:
<Expander x:Name="expander" ExpandDirection="Right" OpacityMask="#6C806969" Background="#FF807171">
... Content ...
<Expander.Style>
<Style TargetType="{x:Type Expander}">
<Setter Property="LayoutTransform">
<Setter.Value>
<ScaleTransform ScaleX="1" />
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsExpanded" Value="True">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation From="0" To="1.2" Duration="0:0:0.35" AutoReverse="False"
Storyboard.TargetProperty="LayoutTransform.(ScaleTransform.ScaleX)" />
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
</Trigger>
</Style.Triggers>
</Style>
</Expander.Style>
</Expander>