出于某种原因,当我将两个扩展器放在一起时,第一个扩展器似乎在第二个扩展器后面,并且不会扩展它旁边的扩展器?有没有办法可以在下面的代码中解决这个问题?
<Grid>
<StackPanel Orientation="Horizontal" Margin="0,0,195,0">
<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="listBox" Storyboard.TargetProperty="(FrameworkElement.LayoutTransform).(ScaleTransform.ScaleX)"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</StackPanel.Triggers>
<Expander x:Name="expander" Expanded="expander_Expanded" ExpandDirection="Right" Width="29">
<ListBox x:Name="listBox">
<ListBoxItem Content="ListBoxItem" VerticalAlignment="Top" />
<ListBoxItem Content="ListBoxItem" VerticalAlignment="Top" />
<ListBoxItem Content="ListBoxItem" VerticalAlignment="Top" />
<ListBox.LayoutTransform>
<ScaleTransform ScaleX="0" ScaleY="1"/>
</ListBox.LayoutTransform>
</ListBox>
</Expander>
<StackPanel Orientation="Horizontal" Margin="0,0,342,0" Width="318">
<StackPanel.Triggers>
<EventTrigger RoutedEvent="Expander.Expanded" SourceName="expander1">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation From="0" To="1.2" Duration="0:0:0.35" Storyboard.TargetName="listBox1" Storyboard.TargetProperty="(FrameworkElement.LayoutTransform).(ScaleTransform.ScaleX)"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</StackPanel.Triggers>
<Expander ExpandDirection="Right" Name="expander1" Width="29">
<ListBox Name="listBox1">
<ListBox.LayoutTransform>
<ScaleTransform ScaleX="0" ScaleY="1" />
</ListBox.LayoutTransform>
<ListBoxItem Content="ListBoxItem" VerticalAlignment="Top" />
<ListBoxItem Content="ListBoxItem" VerticalAlignment="Top" />
<ListBoxItem Content="ListBoxItem" VerticalAlignment="Top" />
</ListBox>
</Expander>
</StackPanel>
</StackPanel>
</Grid>
答案 0 :(得分:1)
删除
中的Width="29"
<Expander x:Name="expander"
Expanded="expander_Expanded"
ExpandDirection="Right"
Width="29">
一切都会好的。