Nested WPF DataGrid DataGridComboBoxColumn with static values

May 15, 2010 at 12:28 PM

Hi,

I have a 2 level nested datagrid. In both levels I use a DataGridComboBoxColumn with static values.At toplevel (level 1) this works without a problem. At sublevel (level 2) the same implementation of

the DataGridComboBoxColumn gives the following error: 'The Element type 'System.Windows.Data.CompositeCollection' does not have an associated TypeConverter to parse the string 'EmployeeContractorSupplier'. The same error occurs when I use an ArrayList.

Below is the XAML code snippet for the datagrid level 2:

<tk:DataGrid ItemsSource="{Binding Source={StaticResource EmailingBodies}}" AutoGenerateColumns="False" Margin="10" CanUserAddRows="False">

<tk:DataGrid.RowBackground >

<LinearGradientBrush EndPoint="-0.136,-0.163" StartPoint ="1.291,1.248">

<GradientStop Color="#FF73A929" Offset ="0.004"/>

<GradientStop Color="#FFF7F7ED" Offset ="0.991"/>

</LinearGradientBrush >

</tk:DataGrid.RowBackground >

<tk:DataGrid.AlternatingRowBackground >

<LinearGradientBrush EndPoint="-0.136,-0.163" StartPoint ="1.291,1.248">

<GradientStop Color="#FF9B9999" Offset ="0.013"/>

<GradientStop Color="#FFFFFFFF" Offset ="1"/>

</LinearGradientBrush >

</tk:DataGrid.AlternatingRowBackground >

<tk:DataGrid.Columns >

<tk:DataGridTextColumn Binding="{Binding ID }" Header="ID" CanUserSort="True" IsReadOnly="True" Visibility="Hidden"></tk:DataGridTextColumn >

<tk:DataGridComboBoxColumn SelectedItemBinding="{Binding Path = LanguageCode}" Header="Taalcode" Width ="SizeToHeader">

<tk:DataGridComboBoxColumn.ItemsSource >

<CompositeCollection >

<sys:String>Employee</sys:String >

<sys:String>Contractor</sys:String >

<sys:String>Supplier</sys:String >

</CompositeCollection >

</tk:DataGridComboBoxColumn.ItemsSource >

</tk:DataGridComboBoxColumn >

<tk:DataGridCheckBoxColumn Binding="{Binding DefaultBody }" Header="Default email Body" CanUserSort="True" IsReadOnly="True" CellStyle="{StaticResource CenterAlignedCellStyle}"></tk:DataGridCheckBoxColumn>

<tk:DataGridTextColumn Binding="{Binding Path_To_Body }" Header="Body-bestand" CanUserSort="True" IsReadOnly="True" Width="1100"></tk:DataGridTextColumn >

</tk:DataGrid.Columns >

</tk:DataGrid >

What am I doing wrong? Please help cause I've tried but I can't figure out.

Thanks,

Daniël