В настоящее время я хотел бы связать свою Height
собственность с Rowdefinition
в Grid
.Я хочу показать строку, если свойство IsOnline
на моем ViewModel
установлено на true
.
Привязка числа как Height
не представляет никакой проблемы, мне просто интересно, как я могпривязать его к Auto
.
My View:
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition Height="{Binding IsOnline, Converter={StaticResource HeightConverter}}"/>
</Grid.RowDefinitions>
My Converter HeightConverter
:
public class HeightConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is bool)
{
if ((bool)value)
{
return "Auto";
}
}
return 0;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}