티스토리 뷰
이것이 필요한지 확인하십시오.
<Window ...>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Expander Grid.Row="0" Collapsed="Expander_Collapsed_1">
<ListView x:Name="Lv1"/>
</Expander>
<GridSplitter Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Top" ShowsPreview="true" ResizeDirection="Rows" Height="5" Background="#FFB82424"/>
<Expander Grid.Row="2" Collapsed="Expander_Collapsed_1">
<ListView x:Name="Lv2" Grid.Row="0"/>
</Expander>
<GridSplitter Grid.Row="3" HorizontalAlignment="Stretch" VerticalAlignment="Top" ShowsPreview="true" ResizeDirection="Rows" Height="5" Background="#FFC51A1A"/>
</Grid>
</Window>
코드 :
private void Expander_Collapsed_1(object sender, RoutedEventArgs e)
{
DependencyObject dobj = VisualTreeHelper.GetParent(sender as Expander);
while (!(dobj is Grid))
dobj = VisualTreeHelper.GetParent(dobj);
int i = Grid.GetRow(sender as Expander);
Grid grd = dobj as Grid;
grd.RowDefinitions[i].Height = GridLength.Auto;
}
출처
https://stackoverflow.com/questions/39917247
댓글