I have a ComboBox whose xaml is as follows
<ComboBox Name="ComboBoxDiscussionType" IsEnabled="{Binding ElementName=ComboBoxDiscussionType, Path=Items.Count, Converter={StaticResource ComboBoxItemsCountToBoolConverter}}"/>
and the converter takes the Items.Count and checks if its greater than 0 if its greater than 0 then enable it else disable it
The goal is enable the ComboBox if the ComboBox only if it has Items in it else disable it, ( self Binding to its item.count )
the following 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 it? right now the above Binding gives me an error