I am struggling binding an enum to aGridComboBoxColumn.
Here is my data class:
public class MediaItem
{
public enum MediaItemType
{
VIDEO=0, PICTURE=1,
}
public MediaItemType Type { get; set; }
public static List AllMediaItemTypes {
get {
return Enum.GetValues(typeof(MediaItemType)).Cast().ToList();
}
}
}
And my column constructor:
var typecol = new GridComboBoxColumn() {
MappingName = "Type",
HeaderText = "Type",
AllowEditing = true,
ItemsSource = MediaItem.AllMediaItemTypes
};
---------------
This mostly works. The menu is correctly populated, the MediaItem has its type set when an item is selected, and the value is shown in the cell after the menu item is selected.
But the cell will be blank if you navigate away.
I have played with SelectedValuePath and DisplayMemberPath, but these seem to only make things worse. I dseid try to express this in XAML as well, but struggled to find a way to provide the ItemsSource with the set of all enum values.
I am happy to use a XAML solution if that is easier. The WPF solution mentioned on the WPF forum does not work for UWP because it uses ObjectDataProvider. The attempt above is from trying to apply a UWP workaround I found for the missing ObjectDataProvider functionality.
Thanks for any help.