WPF MVVM中的单选按钮绑定
有谁能告诉我如何在MVVM中通过单选按钮启用/禁用按钮。通常,它不需要视图模型。您可以使用NotConverter直接绑定两个元素的属性WPF MVVM中的单选按钮绑定,wpf,mvvm,c#-4.0,Wpf,Mvvm,C# 4.0,有谁能告诉我如何在MVVM中通过单选按钮启用/禁用按钮。通常,它不需要视图模型。您可以使用NotConverter直接绑定两个元素的属性 [ValueConversion(typeof(bool), typeof(bool))] public class NotConverter : IValueConverter { public static readonly IValueConverter Instance = new NotConverter(); public obj
[ValueConversion(typeof(bool), typeof(bool))]
public class NotConverter : IValueConverter
{
public static readonly IValueConverter Instance = new NotConverter();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
bool typedValue = (bool)value;
return !typedValue;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return Convert(value, targetType, parameter, culture);
}
}
的ViewModel示例应用程序演示了如何将ViewModel属性绑定到RadioButtons。您想将其绑定到布尔属性还是枚举?我想将其绑定到布尔属性,在某种程度上,它控制了按钮的启用是否在ViewModel上有布尔属性?当它为真(或假)时,您想启用一个按钮吗?