Hi,
after trying around for quite a while, I decided to post a message here because I just don't get the meaning of the different properties of a GridViewComboBoxColumn.
I have a MainViewModel with an ICollectionView property called "ItemsView" which is used as ItemsSource for my RadGridView. The ICollectionView contains items of type PersonViewModel. PersonViewModel has several properties, one of them is called "AgeGroup" and has the type EnumViewModel<EAgeGroup>. The EnumViewModel<TEnum> class has an object property called "LocalizedValue". The MainViewModel also has a property "AvailableAgeGroups" of type ObservableCollection<EnumViewModel<EAgeGroup>> which contains EnumViewModels for all available enum values of type EAgeGroup.
Here is some sample code showing all these classes and properties:
As you can imagine, the EnumViewModel class serves as a "string/localization provider" for enums.
Now, I want to create a ComboBoxColumn which uses the "AvailableAgeGroups" collection as the ItemsSource for the ComboBoxes. The relevant property in the PersonViewModel is, of course, "AgeGroup". So, this property should decide which of the age groups is selected. But, the displayed value should be taken from the "LocalizedValue" property of the value from the "AgeGroup" property. To sum it up, I want to display "PersonViewModel.AgeGroup.LocalizedValue", but the actual item should be "PersonViewModel.AgeGroup".
Now, from what I know from typical .NET controls, I created this column as follows:
But nothing is displayed in the column, only empty cells. However, when I click the Filter button in the header, all possible values are displayed, so it somehow knows the values. Not everything is wrong, it seems. :)
Any advice on this one?
Thanks.
after trying around for quite a while, I decided to post a message here because I just don't get the meaning of the different properties of a GridViewComboBoxColumn.
I have a MainViewModel with an ICollectionView property called "ItemsView" which is used as ItemsSource for my RadGridView. The ICollectionView contains items of type PersonViewModel. PersonViewModel has several properties, one of them is called "AgeGroup" and has the type EnumViewModel<EAgeGroup>. The EnumViewModel<TEnum> class has an object property called "LocalizedValue". The MainViewModel also has a property "AvailableAgeGroups" of type ObservableCollection<EnumViewModel<EAgeGroup>> which contains EnumViewModels for all available enum values of type EAgeGroup.
Here is some sample code showing all these classes and properties:
public class MainViewModel |
{ |
public ICollectionView ItemsView { /* ... */ } |
public ObservableCollection<EnumViewModel<EAgeGroup>> AvailableAgeGroups { /* ... */ } |
} |
public class PersonViewModel |
{ |
public EnumViewModel<EAgeGroup> AgeGroup |
{ |
get { /* ... */ } |
set { /* ... */ } |
} |
} |
public class EnumViewModel<TEnum> |
{ |
public object LocalizedValue { /* ... */ } |
} |
As you can imagine, the EnumViewModel class serves as a "string/localization provider" for enums.
Now, I want to create a ComboBoxColumn which uses the "AvailableAgeGroups" collection as the ItemsSource for the ComboBoxes. The relevant property in the PersonViewModel is, of course, "AgeGroup". So, this property should decide which of the age groups is selected. But, the displayed value should be taken from the "LocalizedValue" property of the value from the "AgeGroup" property. To sum it up, I want to display "PersonViewModel.AgeGroup.LocalizedValue", but the actual item should be "PersonViewModel.AgeGroup".
Now, from what I know from typical .NET controls, I created this column as follows:
<telerik:GridViewComboBoxColumn |
UniqueName="AgeGroup" |
ItemsSource="{Binding AvailableAgeGroups}" |
DisplayMemberPath="LocalizedValue" |
SelectedValueMemberPath="AgeGroup" |
Header="Age Group" |
IsFilterable="True"/> |
But nothing is displayed in the column, only empty cells. However, when I click the Filter button in the header, all possible values are displayed, so it somehow knows the values. Not everything is wrong, it seems. :)
Any advice on this one?
Thanks.