2010-06-16 8 views

답변

0

일반적으로보기 모델이 필요하지 않습니다. NotConverter를 사용하여 두 요소의 속성을 직접 바인딩 할 수 있습니다.

[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); 
    } 

} 

<의 RadioButton NAME = 라디오/> < 버튼의 IsEnabled = {바인딩 경로의 IsChecked =, = ElementName에 라디오 변환기 = {X 정적 NS : NotConverter.Instance}}/>

+0

버튼의 유효성을 제어하는 ​​방식으로 부울 속성에 바인드하려고합니다. –

+0

ViewModel에 부울 속성이 있습니까? 그리고 사실 일 때 (또는 거짓 일 때) 버튼을 활성화하고 싶습니까? – HullCitySteve

+0

예 ..... 정확하게 ..... –

관련 문제