【发布时间】:2012-04-03 10:40:09
【问题描述】:
我有以下转换器:
public class MyConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return Visibility.Hidden;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
...
然后我在 XAML 中使用它,如下所示:
<Resources>
<conv:MyConverter x:Key="MyValToVisibilityConverter" />
</Resources>
...
<CheckBox x:Name="MyCheckBox" Content="Should not be visible"
Visibility="{Binding ElementName=Visibility, Converter={StaticResource MyValToVisibilityConverter}}"
...
这会编译并运行,并且始终将复选框显示为可见。
【问题讨论】:
-
您的哪些 XAML 元素被命名为“可见性”?你的VS输出窗口有错误提示吗?