gridsplitter を使用してグリッドのサイズを変更すると、行は * 他の行が折りたたまれているときにスペースを再利用しません。
3 行のマスター詳細ビューに次のグリッドがあります。中央のスプリッターの上にあるデータ グリッドと、最後の行のコンテンツ コントロール ビュー。スプリッターには、詳細を折りたたむための閉じるボタンがあります。これはすべて、ユーザーがグリッドスプリッターを使用してサイズを変更すると例外があります。
<Grid Margin="3,0">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Style="{StaticResource CollapsableRow}"/><!-- Splitter Here -->
<RowDefinition Style="{StaticResource CollapsableRow}"/>
</Grid.RowDefinitions>
GridSplitter スタイル:
<Style x:Key="gridSplitterStyle" TargetType="{x:Type GridSplitter}">
<Setter Property="Visibility" Value="{Binding IsItemSelected, Converter={StaticResource BoolToShow},ConverterParameter='Visible|Collapsed'}" />
<Setter Property="Width" Value="Auto"/>
<Setter Property="Height" Value="14"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="Border.BorderBrush" Value="#FF6593CF" />
<Setter Property="Border.BorderThickness" Value="0,1,0,0" />
<Setter Property="UIElement.SnapsToDevicePixels" Value="True" />
<Setter Property="UIElement.Focusable" Value="False" />
<Setter Property="Control.Padding" Value="7,7,7,7" />
<Setter Property="Cursor" Value="SizeNS" /></Style>
私が言ったように、グリッドスプリッターを使用してサイズを変更しない限り、折りたたみは正しく機能します。その後、空白は残ります。
編集: HB と codenaked にはシンプルで一貫した提案があったので、データトリガーで成功せずにそれらを実装しようとしました:
<Style x:Key="CollapsableRow" TargetType="{x:Type RowDefinition}">
<Style.Triggers>
<DataTrigger Binding="{Binding SelectedItem, Converter={StaticResource IsNullConverter}}" Value="True">
<Setter Property="RowDefinition.Height" Value="0"/>
</DataTrigger>
<DataTrigger Binding="{Binding SelectedItem, Converter={StaticResource IsNullConverter}}" Value="False">
<Setter Property="RowDefinition.Height" Value="Auto"/>
</DataTrigger>
</Style.Triggers>
</Style>