xamlでSTYLEを使用して次のコードを記述できますか?
cmbEnquiry.IsEnabled = (txtQuotationNo.IsEnabled && txtQuotationNo.IsReadOnly == false);
xamlでSTYLEを使用して次のコードを記述できますか?
cmbEnquiry.IsEnabled = (txtQuotationNo.IsEnabled && txtQuotationNo.IsReadOnly == false);
IDEの前にいないので、メモリからコーディングしようとしているので、これがそのまま機能するかどうかはわかりませんが、他に何もない場合は、MultiBindingの例として役立ちます。
あなたのリソースで:
<local:AndNotConverter x:Key="AndNotConverter" />
<Style ...>
<Setter Property="IsEnabled">
<Setter.Value>
<MultiBinding Converter="{StaticResource AndNotConverter}">
<Binding ElementName="txtQuotationNo" Path="IsEnabled" />
<Binding ElementName="txtQuotationNo" Path="IsReadOnly" />
</MultiBinding>
</Setter.Value>
</Setter>
</Style
コードビハインド:
public class AndNotConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
return (bool)values[0] && !((bool)values[1]);
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter,
System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
編集:
コードを確認したところ、期待どおりに機能します。