我想要一个侧边栏,可以通过按下 ToggleButton 来隐藏它,并由用户使用 GridSplitter 控件通过鼠标重新调整大小。最后,我希望它看起来像这样:
(请看图1)
和:
(请看图2)
这是我到目前为止所拥有的:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<GridSplitter Grid.Column="1" HorizontalAlignment="Left" Width="4"
BorderThickness="1,0" Foreground="{x:Null}" Background="#01000000" BorderBrush="{DynamicResource ColorControlBorder}"/>
<Grid x:Name="grid" Grid.Column="1" Margin="4,0,0,0" Background="{DynamicResource IconErrorFilter}" RenderTransformOrigin="0.5,0.5">
<Grid.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Grid.RenderTransform>
<Expander x:Name="expander2" Style="{DynamicResource AddExpanderStyle}"
ExpandDirection="Up" Background="#D8FFFFFF" BorderBrush="{DynamicResource ColorControlBorder}"
DataContext="{Binding FilterTypesPMod}" d:LayoutOverrides="Height" VerticalAlignment="Bottom">
<Expander.Resources>
<CollectionViewSource x:Key="CollectionFilterTypes" Source="{Binding FilterTypes}">
<CollectionViewSource.SortDescriptions>
<ComponentModel:SortDescription PropertyName="Order" Direction="Ascending" />
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>
</Expander.Resources>
<Grid>
<ItemsControl BorderThickness="0" Background="Transparent" BorderBrush="Transparent"
ItemsSource="{Binding Source={StaticResource CollectionFilterTypes}}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Bla... />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</Expander>
</Grid>
<ToggleButton x:Name="toggleButton" Grid.Column="1" HorizontalAlignment="Left" Style="{DynamicResource CollapsingToggleButtonStyle}" Background="{DynamicResource ColorMainForeground}" RenderTransformOrigin="0.5,0.5">
<ToggleButton.LayoutTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</ToggleButton.LayoutTransform>
</ToggleButton>
当我在没有 GridSplitter 的情况下使用它时,它工作正常(调整大小除外):当我按下 ToggleButton 时,Grid 'grid' 的内容消失并且 GridColumn(1) 变得更小,为 GridColumn(0) 留下更多空间。但是,一旦我放入 GridSplitter,自动调整大小就会停止。有谁知道如何解决这个问题?