Show some static values ​​in wpf datagrid link list column

I am trying to use a DataGrid whose first column is a ComboxBox . This ComboxBox has hard-coded static values; possible values ​​are: Employee, Contractor, Supplier

How to show some static values ​​in a DataGrid without binding to a DataSource . I am new to WPF, so a more detailed explanation will help.

+4
source share
2 answers

if you mean the wpf tooltit toolkit, you can do it like this:

  <dg:DataGridComboBoxColumn Header="String Column" SelectedItemBinding="{Binding Path=RoleProperty}"> <dg:DataGridComboBoxColumn.ItemsSource> <CompositeCollection> <system:String>Employee</system:String> <system:String>Contractor</system:String> <system:String>Supplier</system:String> </CompositeCollection> </dg:DataGridComboBoxColumn.ItemsSource> </dg:DataGridComboBoxColumn> 

in this, the displayed items have the RoleProperty property. you will also need to define the xnl namespace at the top of your xaml (with the rest of them, for example:

  xmlns:system="clr-namespace:System;assembly=mscorlib" 

to include a namespace. (to access the strings)

+11
source

You can simply use the standard ComboBox with static values ​​like ComboBoxItems, for example:

 <ComboBox> <ComboBoxItem>Employee</ComboBoxItem> <ComboBoxItem>Contractor</ComboBoxItem> <ComboBoxItem>Supplier</ComboBoxItem> </ComboBox> 
+3
source

All Articles