Combobox Binding on DataGrid Problem

Nov 16, 2008 at 12:33 AM
Can someone please explain to me (urgently) if this is a bug, or have I overlooked something.

I have been trying to bind a list of Linq items to a datagrid.  The datagrid uses template columns some of which have comboboxes in them.
I noticed lots of changes when I updated my Preview Toolkit to Ver 1; such as DataFieldBinding changing to Binding.   so it is possible I am getting this wrong.

Here is my window code...

<Window x:Class="DataGridTest.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit"
    Title="Window1" Height="300" Width="300">
    <Window.Resources>
        <CollectionViewSource x:Key="VATStats" x:Name="VATStatsCollection" />
    </Window.Resources>
    <DockPanel>
        <Button DockPanel.Dock="Bottom" Width="125" Height="25" Click="Button_Click">Submit Changes</Button>
        <dg:DataGrid Name="mygrid">
            <dg:DataGrid.Columns>
                <dg:DataGridTextColumn DataFieldBinding="{Binding citemid}" Header="Item ID" />
                <dg:DataGridTextColumn DataFieldBinding="{Binding cvatid}" Header="VAT ID" />
                <dg:DataGridTemplateColumn Header="Vat State">
                    <dg:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Path=vatstat.cvatname, Mode=OneWay}" />
                        </DataTemplate>
                    </dg:DataGridTemplateColumn.CellTemplate>
                    <dg:DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <ComboBox ItemsSource="{Binding Source={StaticResource VATStats}}" SelectedValue="{Binding vatstat}" SelectedValuePath="." DisplayMemberPath="cvatname" />
                        </DataTemplate>
                    </dg:DataGridTemplateColumn.CellEditingTemplate>
                </dg:DataGridTemplateColumn>
            </dg:DataGrid.Columns>
        </dg:DataGrid>
    </DockPanel>
</Window>

In code I set the collection source, and the grid itemssource, plus I have a submit button.

If I revert back to the earlier version of the tooklit, I can change the combobox value in each row to a different value.

Using the current version (and changing DataFieldBinding to Binding), when I select a combo in one row, all other rows that I edit after opening the window get set to null.

Is this a bug?
Nov 16, 2008 at 12:46 AM
An update...

I have just tried changing my Combo Column to...

                <dg:DataGridComboBoxColumn Header="Vat State" ItemsSource="{Binding Source={StaticResource VATStats}}" SelectedValueBinding="{Binding vatstat}" DisplayMemberPath="cvatname" />

When I select a value in the combobox, every row in the grid displays the selected value.
As I scroll up and down in the grid, every row in the grid changes as the current row changes.

It is as if it is not binding to each individual row.

Ideas?
Coordinator
Mar 30, 2009 at 9:57 PM
This should be fixed in the March 2009 release.  The issue is relating to IsSynchronizedWithCurrentItem being set to true.