【发布时间】:2018-10-24 22:17:51
【问题描述】:
目前我想将我的Height 属性绑定到Rowdefinition 上的Grid。如果我的ViewModel 上的属性IsOnline 设置为true,我想显示该行。
将数字绑定为Height 完全没有问题,我只是想知道如何将它绑定到Auto。
我的观点:
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition Height="{Binding IsOnline, Converter={StaticResource HeightConverter}}"/>
</Grid.RowDefinitions>
我的转换器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();
}
}
【问题讨论】:
标签: c# wpf xamarin xamarin.forms binding