8,757
社区成员
发帖
与我相关
我的任务
分享
</UserControl.Resources>
<local:EnableConverters x:Key="enableConverter"/>
</UserControl.Resources>
<TextBox Width="100" Height="25" Foreground="Black" x:Name="txtName" IsEnabled="{Binding ElementName=checkBox1, Path=IsChecked,Converter={StaticResource enableConverter}}" />
<CheckBox Content="CheckBox" Height="16" Name="checkBox1" />
public class EnableConverters : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
bool? checkValue = (bool?)value;
if (checkValue.HasValue && checkValue.Value)
return false;
else
return true;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
<TextBox Width="100" Height="25" Foreground="Black" x:Name="txtName" IsEnabled="{Binding ElementName=checkBox1, Path=IsChecked}" />
<CheckBox Content="CheckBox" Height="16" Name="checkBox1" />