현재 컨트롤의 IsEnabled 속성에 두 값의 OR을해야 할 때 테두리가있는 보이지 않는 컨테이너 컨트롤을 사용하여 끝나고 IsEnabled 컨트롤과 컨테이너 중 하나를 설정해야합니다.IsEnabled 속성을 두 값의 OR에 바인딩하는 방법?
더 좋은 방법이 있습니까? 그렇지 않은 경우이 작업을 수행하는 데있어 가장 간단한 컨트롤은 무엇입니까?
미리 감사드립니다.
현재 컨트롤의 IsEnabled 속성에 두 값의 OR을해야 할 때 테두리가있는 보이지 않는 컨테이너 컨트롤을 사용하여 끝나고 IsEnabled 컨트롤과 컨테이너 중 하나를 설정해야합니다.IsEnabled 속성을 두 값의 OR에 바인딩하는 방법?
더 좋은 방법이 있습니까? 그렇지 않은 경우이 작업을 수행하는 데있어 가장 간단한 컨트롤은 무엇입니까?
미리 감사드립니다.
경우 결합을 통해, 당신은 multi-value converter와 함께 MultiBinding를 사용할 수 있습니다.
는 솔직히, 나는 쉽게 내 자신의 솔루션을 찾을 수 있습니다 : D 그러나 나는 당신이 말하는 것을 얻을. –
는 전달 된 값을 나 컨버터와 MultiBinding
을 사용할 수 있습니다. IsEnabled
이 설정되어
당신은이 같은 변환기를 사용할 수 있습니다
public class BooleanOrConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
foreach (object value in values)
{
if ((value is bool) && (bool)value == true)
{
return true;
}
}
return false;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotSupportedException("BooleanOrConverter is a OneWay converter.");
}
}
을 그리고 이것은 당신이 그것을 사용하는 것이 방법입니다
<myConverters:BooleanOrConverter x:Key="BooleanOrConverter" />
...
<ComboBox Name="MyComboBox">
<ComboBox.IsEnabled>
<MultiBinding Converter="{StaticResource BooleanOrConverter}">
<Binding ElementName="SomeCheckBox" Path="IsChecked" />
<Binding ElementName="AnotherCheckbox" Path="IsChecked" />
</MultiBinding>
</ComboBox.IsEnabled>
</ComboBox>
당신이 ViewModel에 바인딩하는 경우가 집계 속성을 만들 수 있으며, 그 대신 바인딩하십시오. – dlev
방문 http://stackoverflow.com/questions/945427/c-sharp-wpf-isenabled-using-multiple-bindings – GANI