【发布时间】:2020-12-21 13:06:16
【问题描述】:
我有一个转换器,它有一个属性 VisibleLength
public class BoolToGridLengthConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return ((bool)value == true) ? new GridLength(0) : new GridLength(VisibleLength);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
public double VisibleLength { get; set; }
}
在 App.xaml 中,我将资源定义为
<Application.Resources>
<ns:BoolToGridLengthConverter
x:Key="boolToGridLengthConverter"
/>
</Application.Resources>
并在 xaml 中用作
<RowDefinition Height="{Binding Path=boolProperty, Converter={StaticResource boolToGridLengthConverter}}" />
如何使用该属性将 VisibleLenght property=doubleValue 从 xaml 传递给转换器。
【问题讨论】:
标签: wpf converters staticresource