The next XAML hides the bottom line when you uncheck the box. Everything will be fine until you resize it with gridsplitter. Then checking / unchecking the box does nothing. Given that the converter sets the height to 0, I expected the line to hide. What's happening? How can I reset the heights after moving the separator?
<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>
Converter
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();
}
}
source
share