• 2.2k
  • 1
  • 3.5k

DataGridComboBoxColumn in DataGrid

Feb 12 2012 12:59 PM

Hello. this is my problem.

I have a DataGrid, consisting of 2 columns, one type DataGridTextColumn, the other DataGridComboBoxColumn.
All columns are loaded with the same value, "Item 0" "item 1", "item 3".

This is the situation: in the first column I have the values in the second column, DataGridComboBoxColumn, I don't see ANYTHING.

If I click in any cell of the second column, I get the ComboBox populated with the correct values: ("A1", "A2", "A3")

Where is the error and why the second column is empty?

Below I post the code to which I refer.
Many thanks

'Load data
Dim dt As New DataTable()
Dim dr As DataRow

dt.Columns.Add(New DataColumn("PopolaTEST", GetType(String)))

Dim i As Integer
For i = 0 To 3
        dr = dt.NewRow()         
        dr(0) = "Item " + i.ToString()
Next i

Dim dv As New DataView(dt)
Test.ItemsSource = dv

Code in the del Grid

Title="MainWindow" Height="350" Width="525">
<DataGrid x:Name="Test" Margin="5,5,5,77" AutoGenerateColumns="False" AlternatingRowBackground="#FFE5D429" AlternationCount="2">
<DataGridTextColumn Header="COL A" Binding="{Binding Path=PopolaTEST}"></DataGridTextColumn>
<DataGridComboBoxColumn Header="COL B" SelectedItemBinding="{Binding Path=PopolaTEST}">
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="18,251,0,0" Name="Button1" VerticalAlignment="Top" Width="75" />