public class GroupcaptionConverterMultiColumnDropDownList : IValueConverter public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (!(parameter is GridMultiColumnDropDownList)) return value; var column = parameter as GridMultiColumnDropDownList; var record = value as EmployeeInfo; var itemsSource = column.ItemsSource as ObservableCollection<CompanyItem>; foreach (var item in itemsSource) { if (record.CountryCode == (item as CompanyItem).CountryCode) return (item as CompanyItem).CountryName; } return null; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } } |
void GroupColumnDescriptions_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) { var group = e.NewItems[0] as GroupColumnDescription; if (group.ColumnName == "CountryCode") group.Converter = new GroupcaptionConverterMultiColumnDropDownList(); } } |