0

I use data grid to display list of data to user. So I have data two columns that bind to Observable list in View-Model, And another column of combo-box that bind to enum. when I run the code column with combo-box display nothing other columns work as expected.

<UserControl.Resources>
        <ObjectDataProvider x:Key="ActionEnumList" MethodName="GetValues" ObjectType="{x:Type core:Enum}">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="desktop:ActionsEnum"/>
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
    </UserControl.Resources>
<DataGrid ItemsSource="{Binding InactiveTrains}" AutoGenerateColumns="False" >
                    <DataGrid.Columns>
                        <DataGridTextColumn Width="100" Header="Train ID" Binding="{Binding TID}" />
                        <DataGridTextColumn Width="*" Header="Name" Binding="{Binding Name}" />
                        <DataGridComboBoxColumn ItemsSource="{Binding Source={StaticResource ActionEnumList}}"/>
                    </DataGrid.Columns>
                </DataGrid>

enum

public enum ActionsEnum
    {
        Cancelled=1,
        Activated=2,
        Delayed=3,
        Rescheduled=4
   }

view-model

public ObservableCollection<Train> InactiveTrains { get; set; }
  • Have a look at this [thread](https://stackoverflow.com/questions/37092145/how-to-use-an-objectdataprovider-to-bind-an-enum-to-a-combobox-in-xaml) – Pavel Anikhouski Jul 06 '19 at 08:10
  • @OsuraWeerasinghe: The values are not supposed to be shown until your open the `ComboBox`. Did you do this? I can't reproduce your issue then. – mm8 Jul 08 '19 at 13:46
  • @mm8:Thanks for Commenting. Combobox can't open that was the issue. The wired thing is I try the same code in new project by importing then it works. I don't try to change project configurations. I use .net 4.5, I'm not sure whether it makes the trouble. I'm at the end of a project and don't want to break hole project by changing version. – Osura Weerasinghe Jul 08 '19 at 14:48

0 Answers0