例如,我有一个类似这样的视图模型:
public class MyViewModel
{
public ObservableCollection { get; set; }
}
public abstract class Person { }
public class Employee : Person { }
public class Boss : Person { }
根据我不想对我的 ListItemTemplate 进行一些更改的人的类型。我有一个像这样的值转换器:
public object Convert(object value, Type targetType, object parameter, string language)
{
if (value == null) return Visibility.Collapsed;
return value is Boss ? Visibility.Visible : Visibility.Collapsed;
}
如何将 Visibilty 属性绑定到转换器?
我做过的事情:
<Border Visibility="{Binding Path=self, Converter={StaticResource BossVisibilityConverter}}">
<Border Visibility="{Binding Path=this, Converter={StaticResource BossVisibilityConverter}}">