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. Image for the cookie policy date
close icon

Binding enum to SfDatagrid GridComboBoxColumn

How can I bind an enum to SfDatagrid GridComboBoxColumn?
Example :

public enum Gender
{
Male,
Female
}

I need to display values 'Male' and 'Female' in the combobox  using MVVM.

1 Reply

JG Jai Ganesh S Syncfusion Team August 10, 2015 08:17 AM UTC

Hi Rahulan,

Thank you for contacting Syncfusion Support.

We have analyzed your query. You can bind the enum to SfDatagrid by using “ObjectDataProvider class.


Code Snippet [XAML]:


<Window.Resources>

        <ObjectDataProvider x:Key="enumdata" MethodName="GetValues" ObjectType="{x:Type sys:Enum}">

            <ObjectDataProvider.MethodParameters>

                <x:Type TypeName="local:Gender" />

            </ObjectDataProvider.MethodParameters>

        </ObjectDataProvider>

</Window.Resources>


<Syncfusion:GridComboBoxColumn MappingName="EmployeeGender" ItemsSource="{Binding Source={StaticResource enumdata}}"/>


We have also prepared the sample based on this and please find the sample under the following location,


Sample: http://www.syncfusion.com/downloads/support/directtrac/141092/ze/SfDataGridComboBoxDemo-738189882


Please let us know if you need further assistance.


Thank you,

Jai Ganesh S


Loader.
Live Chat Icon For mobile
Up arrow icon