我知道这看起来像是一个重复的问题,但我已经尝试过在类似问题中提出的解决方案。
<UserControl.Resources>
<common:BooleanToVisibilityMultipleConverter x:Key="BoolToVisibilityMultiConverter"/>
</UserControl.Resources>
<Grid Margin="5">
---------------------------------------------------------------------
---------------------------------------------------------------------
<Button Grid.Row="8" Grid.Column="2"
Margin="5"
VerticalContentAlignment="Center" HorizontalAlignment="Right"
Background="{x:Static sds:AppBrushes.Green}"
MinWidth="{StaticResource SdsButtonMinWidth}"
Content="{x:Static res:Resources.UpdatePlantNameButton}"
Command="{Binding CreateDatabaseCommand}">
<Button.Visibility>
<MultiBinding Converter="{StaticResource BoolToVisibilityMultiConverter}">
<Binding Path="IsDatabaseCreated"/>
<Binding Path="IsHistory"/>
</MultiBinding>
</Button.Visibility>
</Button>
</Grid>
</UserControl>
我的转换器代码 -
namespace ABB.SDS.Batch.Common
{
public class BooleanToVisibilityMultipleConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
return values.OfType<bool>().All(b => b) ? Visibility.Visible : Visibility.Hidden;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
我只是在一个地方提到转换器,那是在定义了转换器之后。我仍然得到这个例外 “该方法或操作未实施。 导致:'提供价值'System.Windows.StaticResourceExtension'引发了异常。行号'111'和行位置'18'“
我错过了什么?是否有任何其他用例抛出此异常?