Con el siguiente XAML, la fila inferior se oculta cuando se desmarca la casilla de verificación. Todo está bien hasta que lo cambies de tamaño con el divisor de grillas. Luego, marcar/desmarcar la casilla de verificación no hace nada. Dado que el convertidor establece la Altura en 0, esperaba que la fila se ocultara. ¿Que esta pasando? ¿Cómo puedo restablecer las alturas después de mover el divisor?¿Cómo restablecer la altura de la fila de la grilla después de usar el divisor?
<Grid>
<Grid.Resources>
<m:CheckedToLengthConverter x:Key="checkedToLengthConverter" />
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="3*" />
<RowDefinition Height="{Binding Mode=OneWay, ElementName=ShowBottomCheckBox, Path=IsChecked, Converter={StaticResource checkedToLengthConverter}, ConverterParameter=2}" />
</Grid.RowDefinitions>
<Border Background="Blue" />
<CheckBox Name="ShowBottomCheckBox" IsChecked="True" />
<GridSplitter HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Height="5" />
<Border Background="Red" Grid.Row="1" />
</Grid>
Convertidor:
public class CheckedToLengthConverter: IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if ((bool)value)
return new GridLength(int.Parse(parameter.ToString()), GridUnitType.Star);
return new GridLength(0, GridUnitType.Pixel);
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
¿Podría dar un ejemplo? No puedo hacer que funcione. – Manuel
@Manuel, he creado algo que funciona para mí. – Phil