Universal Windows Platform (UWP)
A Microsoft platform for building and publishing apps for Windows desktop devices.
3,003 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi, I have been trying to collapse 1 of 2 grids inside a grid, but the parent grid always collapses these 2 children grids.
<Grid x:Name="ParentGrid">
<Grid x:Name="ChildGrid1">
</Grid>
<Grid x:Name="ChildGrid2">
</Grid>
</Grid>
...
this.ChildGrid1.Visibility = Visibility.collapsed;
I think I found out why the ParentGrid collapsed all is that I put the ParentGrid in another Grid that is in a ScrollViewer, but I put the ScrollViewer in another Grid with RowDefinition.Height="Auto". So If I do not use the ScrollViewer, I can make the ChildGrid1 collapses. And If I set the RowDefinition.Height from "Auto" to "*", I can use the ScrollViewer to scroll the content and also make the childGrid1 collapses.
<Grid x:Name="ParentGrid">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" x:Name="ChildGrid1">
</Grid>
<Grid Grid.Row="1" x:Name="ChildGrid2">
</Grid>
</Grid>
...
this.ChildGrid1.Visibility = Visibility.collapsed;
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<!--RowDefinition Height="Auto"-->
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ScrollViewer Grid.Row="1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!--An User Control that has the ParentGrid (Grid)-->
<userControls:MyUserControl Grid.Row="0"/>
<userControls:MyUserControl2 Grid.Row="1"/>
</Grid>
</ScrollViewer>
</Grid>