b.
❔ How do I display an enum in a DataGridComboBoxColumn?
<DataGrid Name="dataGrid" ItemsSource="{Binding TaskVMs}" AutoGenerateColumns="False" SelectionMode="Single"
SelectedItem="{Binding SelectedItem, Mode=TwoWay}">
<DataGrid.Columns>
<DataGridTextColumn Header="Task Name" Width="250" Binding="{Binding Name, Mode=TwoWay}" />
<DataGridComboBoxColumn Header="Priority" Width="200"
SelectedItemBinding="{Binding Priority, Mode=TwoWay}"
ItemsSource="{Binding PriorityEnum}"/>
<DataGridTextColumn Header="Due Date" Binding="{Binding DeadLine, Mode=TwoWay}" Width="200" />
</DataGrid.Columns>
<DataGrid.ContextMenu>
<ContextMenu>
<MenuItem Header="Delete Task" Command="{Binding DeleteItemCommand}" />
</ContextMenu>
</DataGrid.ContextMenu>
</DataGrid>
<DataGrid Name="dataGrid" ItemsSource="{Binding TaskVMs}" AutoGenerateColumns="False" SelectionMode="Single"
SelectedItem="{Binding SelectedItem, Mode=TwoWay}">
<DataGrid.Columns>
<DataGridTextColumn Header="Task Name" Width="250" Binding="{Binding Name, Mode=TwoWay}" />
<DataGridComboBoxColumn Header="Priority" Width="200"
SelectedItemBinding="{Binding Priority, Mode=TwoWay}"
ItemsSource="{Binding PriorityEnum}"/>
<DataGridTextColumn Header="Due Date" Binding="{Binding DeadLine, Mode=TwoWay}" Width="200" />
</DataGrid.Columns>
<DataGrid.ContextMenu>
<ContextMenu>
<MenuItem Header="Delete Task" Command="{Binding DeleteItemCommand}" />
</ContextMenu>
</DataGrid.ContextMenu>
</DataGrid>
public enum TaskPriority
{
Low,
Medium,
High,
None
}
public enum TaskPriority
{
Low,
Medium,
High,
None
}
4 replies