也许我误解了如何使用IValueConverter或数据绑定(很可能),但我目前正在尝试根据字符串的值设置DataGridTextColumn的IsReadOnly属性。这里是XAML:绑定IsReadOnly使用IValueConverter
<DataGridTextColumn Binding="{Binding Path=GroupDescription}" Header="Name"
IsReadOnly="{Binding Current,
Converter={StaticResource currentConverter}}"/>
这里是我的转换器:
public class CurrentConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
string s = value as string;
if (s == "Current")
{
return false;
}
else
{
return true;
}
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotSupportedException();
}
}
目前,该列始终是可编辑,转换,似乎什么也不做。有没有人有一些想法,为什么发生这种情况?
什么是问题/问题? – Szymon
更新了问题的结尾,希望它不太含糊...... –
IsReadOnly不可绑定。请参阅我的答案http://stackoverflow.com/questions/18443063/bind-datagrid-textbox-enable-based-on-checkbox-property/18444724#18444724 – Shoe