but the problem is when you have 10 Rows in the grid were set to Auto and you hide the content of Row 2 to Row9 then you will have a big empty space
Sorry for the unclear information. The empty space is the row spacing, please set RowSpacing
to 0 for the parent grid. The below code could hide the row successfully, please check it. And here is the working gif: https://imgur.com/q0d6pdD
<Grid RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition x:Name="this_is_the_row" Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid Grid.Row="0" ColumnSpacing="0" RowSpacing="0" BackgroundColor="LightBlue">
<Grid.Triggers>
<DataTrigger TargetType="Grid" Binding="{Binding Source={x:Reference LabelPostGender}, Path=Text, TargetNullValue=''}" Value="testing">
<Setter Property="IsVisible" Value="False" />
</DataTrigger>
</Grid.Triggers>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Margin="5" Text="Treatments : " TextColor="Red" VerticalOptions="Center" />
<Entry x:Name="LabelPostGender" Grid.Row="1" Margin="5" />
<BoxView Grid.Row="2" HeightRequest="1" BackgroundColor="LightGray" HorizontalOptions="FillAndExpand" />
</Grid>
<Label Text="the second row" Grid.Row="1"/>
<BoxView HeightRequest="150" Grid.Row="2" BackgroundColor="Red">
<BoxView.Triggers>
<DataTrigger TargetType="BoxView" Binding="{Binding Source={x:Reference LabelPostGender}, Path=Text, TargetNullValue=''}" Value="testing">
<Setter Property="HeightRequest" Value="0" />
</DataTrigger>
</BoxView.Triggers>
</BoxView>
<Label Text="the 4th row" Grid.Row="3"/>
</Grid>