views:

75

answers:

1

I am trying to use a combobox inside a datagrid, but I am running into an issue. Here is the code:

<sdk:DataGrid AutoGenerateColumns="False" Margin="6,71,6,0"  Name="dgridDeptNums" Loaded="dgridDeptNums_Loaded" Height="226" VerticalAlignment="Top">
            <sdk:DataGrid.Columns>
                <sdk:DataGridTemplateColumn Header="Speciality" Width="*">
                    <sdk:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <ComboBox SelectedValue="{Binding Department, Mode=TwoWay}">
                                <ComboBox.Items>
                                    <ComboBoxItem>Information Technology</ComboBoxItem>
                                    <ComboBoxItem>Human Resources</ComboBoxItem>
                                    <ComboBoxItem>Engineering</ComboBoxItem>
                                 etc...
                                </ComboBox.Items> 
                            </ComboBox>
                        </DataTemplate>
                    </sdk:DataGridTemplateColumn.CellTemplate>
                </sdk:DataGridTemplateColumn>
                <sdk:DataGridTextColumn Header="# of Supervisors" Binding="{Binding Providers, Mode=TwoWay}" Width="*"/>
                <sdk:DataGridTextColumn Header="# of Managers" Binding="{Binding Midlevels, Mode=TwoWay}" Width="*"/>
            </sdk:DataGrid.Columns>
        </sdk:DataGrid>

The issue is that I want to databind the department, but all I get is System.Windows.Controls.ComboBoxItem. I am sure I am missing something here, so any help is appreciated.

Wade

+2  A: 

instead of <ComboBoxItem>Information Technology</ComboBoxItem>

use <sys:string>Information Technology</sys:string>

where

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

Michael S. Scherotter
Do I need to keep that within the <ComboBox.Items> tag?
Wade73
That was it, thanks!
Wade73