Once the grating grid is used to resize the grid, row * will not recover space when other rows are collapsed.
I have the following grid in the main view with three rows. The data grid is at the top of the splitter in the middle and the contentcontrol is on the last line. The splitter has a closed button to collapse parts. All this works with the exception that after resizing the user using gridsplitter grid.
<Grid Margin="3,0"> <Grid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition Style="{StaticResource CollapsableRow}"/> <RowDefinition Style="{StaticResource CollapsableRow}"/> </Grid.RowDefinitions>
GridSplitter Style:
<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>
As I said, the crash works correctly if the gridsplitter grid is used to resize. After that, gaps remain.
EDIT: HB and Kononi had simple and consistent sentences, so I tried to implement them without success in the data trigger:
<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>
source share