Xaml 无法将 ResourceExtension 转换为 IValueConverter

问题描述 投票:0回答:0

我的问题是关于这个问题: 我在 Xaml 样式声明中有这个属性,给我一个错误消息来尝试转换它。 返回的警告信息是这样的: “对象类型“Syste.Windows.StaticResourceExtension”无法转换为“System.Windows.Data.IvalueConverter”

xmlns:System="clr-namespace:System;assembly=mscorlib"

   <ResourceDictionary>
     <BooleanToVisibilityConverter x:Key="BoolToVis"/>
   </ResourceDictionary>

<Style x:Key="TextBlockTestStyle" TargetType="TextBlock">
    <Setter Property="Visibility" Value="{Binding varCodeBehind,Converter={StaticResource BoolToVis}, NotifyOnSourceUpdated=True ,UpdateSourceTrigger=PropertyChanged}"/>
</Style>

变量varCodeBehind在code behind中声明,是Boolean类型

如何避免这个警告?

wpf xaml styles converters visibility
© www.soinside.com 2019 - 2024. All rights reserved.