ViewModelのブールプロパティにバインドしている2つのRadioButtonがあります。残念ながら、'targetType'パラメーターがnullであるため、コンバーターでエラーが発生します。
これで、targetTypeパラメーターがnullになることを期待していませんでした(TrueまたはFalseを期待していました)。ただし、RadioButtonのIsCheckedプロパティがnull許容のブール値であることに気付いたので、この種の説明があります。
XAMLで何かを修正できますか、それともソリューションの既存のコンバーターを変更する必要がありますか?
これが私のXAMLです。
<RadioButton Name="UseTemplateRadioButton" Content="Use Template"
GroupName="Template"
IsChecked="{Binding UseTemplate, Mode=TwoWay}" />
<RadioButton Name="CreatNewRadioButton" Content="Create New"
GroupName="Template"
IsChecked="{Binding Path=UseTemplate, Mode=TwoWay, Converter={StaticResource InverseBooleanConverter}}"/>
これは、ソリューション全体で使用している既存のコンバーターです。InverseBooleanConverter:
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if ((targetType != typeof(bool)) && (targetType != typeof(object)))
{
throw new InvalidOperationException("The target must be a boolean");
}
return !(((value != null) && ((IConvertible)value).ToBoolean(provider)));
}