You can create IValueConverterone that converts your list into a separate list:
public class DistinctConverter : IValueConverter
{
public object Convert(
object value, Type targetType, object parameter, CultureInfo culture)
{
var values = value as IEnumerable;
if (values == null)
return null;
return values.Cast<object>().Distinct();
}
public object ConvertBack(
object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}
add this to resources:
<local:DistinctConverter x:Key="distinctConverter" />
and use it as follows:
<ComboBox ItemsSource="{Binding Vals, Converter={StaticResource distinctConverter}}" />
svick source
share