I have a ComboBox whose xaml looks like this
<ComboBox Name="ComboBoxDiscussionType" IsEnabled="{Binding ElementName=ComboBoxDiscussionType, Path=Items.Count, Converter={StaticResource ComboBoxItemsCountToBoolConverter}}"/>
and the converter takes Items.Count and checks if it exceeds more than 0, if it is more than 0, then allow it to be disabled again.
The goal is to enable the ComboBox, if the ComboBox, only if it contains elements in it, disconnects it, (self Binding to its item.count)
next is my converter,
public class ComboBoxItemsCountToBoolConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (int)value > 0;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
How do I achieve this? right now the aforementioned binding gives me an error
user677607
source
share