We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Binding an Enum to a GridComboBoxColumn in UWP

Thread ID:

Created:

Updated:

Platform:

Replies:

127394 Nov 12,2016 08:27 AM UTC Nov 14,2016 12:30 PM UTC UWP 1
loading
Tags: SfDataGrid
Duane Eitzen
Asked On November 12, 2016 08:27 AM UTC

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.

Jai Ganesh S [Syncfusion]
Replied On November 14, 2016 12:30 PM UTC

Hi Duane, 
 
We have prepared a sample for binding Enum values to GridComboBoxColumn and it working fine in our end, 
 
public enum GetDetails 
{ 
    Item1, 
    Item2, 
    Item3, 
    Item4, 
    Item5 
}                      
 
var enumvalues = Enum.GetValues(typeof(GetDetails)).Cast<GetDetails>(); 
var typecol = new GridComboBoxColumn() 
{ 
    MappingName = "EnumType", 
    HeaderText = "EnumType", 
    AllowEditing = true, 
    ItemsSource = enumvalues.ToList() 
}; 
this.sfGrid.Columns.Add(typecol); 
 
 
Could you please check the above sample and still if you are facing the issue, then please modify the above sample to replicate the issue? This would be more helpful for us to proceed further. 
 
Regards, 
Jai Ganesh S  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;