0

出于某种原因,当我将两个扩展器并排设置时,第一个扩展器似乎在第二个扩展器之后,并且不会扩展它旁边的扩展器集?有没有办法可以在下面的代码中解决这个问题?

<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>

4

1 回答 1

1

删除Width="29"_

<Expander x:Name="expander"
          Expanded="expander_Expanded"
          ExpandDirection="Right"
          Width="29">

一切都会好起来的。

于 2012-04-15T16:02:18.980 回答