ComboBox in a Grid displayed as RowLevelDetails works with Keyboard but not Mouse

Apr 27, 2009 at 7:22 PM
Edited Apr 27, 2009 at 9:15 PM
Hi there.

More Grid Fun!

I have a Grid which is used to display a heirarchical Domain Objects.  When I click no the parent row, the RowDetailsTemplate 
is defined as a grid as well.

For Example assume my observableCollection heirarchy is Customer which has a Collection of Orders.  When I click on a customer in the grid, my RowDetailsTemplate shows me a "nested" grid of Orders.

This solution is from Colin E. and it works great especially for displaying readonly information.

The child grid (the Orders) can even be edited as well!  What I am now seeing is the need for a combobox for one of the column in the nested Grid.

I was able to get the ComboBox to show but it has very strange behavior:  I can select from the combobox only when I use the keyboard.  When I use the mouse, it appears to ignore the selection make an resets to the loaded (bound) value.
 
Help!  and thanks 8->  
Tracy








Apr 27, 2009 at 9:49 PM
Here is the associate code sample:


       <dg:DataGrid 
             CanUserAddRows="False" 
             Name="DataGridCustomersONE" 
             ItemsSource="{Binding Path=Customers}" 
             Height="Auto" 
             VerticalAlignment="Top"
             AutoGenerateColumns="False"
             RowDetailsVisibilityMode="Visible" 
            Grid.Row ="0"
            >
                  <dg:DataGrid.RowDetailsTemplate>
                    <DataTemplate>
                        <StackPanel>
                            <dg:DataGrid  ItemsSource="{Binding Path=Orders}" 
                                         Name="dataGrid2" AutoGenerateColumns="False">
                                <dg:DataGrid.Columns>
                                    <dg:DataGridTextColumn Header="Desc" Binding="{Binding Path=Desc,ValidatesOnDataErrors=True,Mode=TwoWay}" 
Width="150" EditingElementStyle="{StaticResource CellEditStyle}" />

                                    <dg:DataGridComboBoxColumn Header="Order Status" 
                                           x:Name="dgComboBoxColumnDuplicate"
                                           SelectedValueBinding="{Binding OrderStatus}"
                                           SelectedValuePath="Code"
                                           DisplayMemberPath="Name"
                                            >
                                        <dg:DataGridComboBoxColumn.ElementStyle>
                                            <Style TargetType="{x:Type ComboBox}">
                                                <Setter Property="ItemsSource" Value="{Binding Path=DataContext.StatusList, 
RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" />
                                            </Style>
                                        </dg:DataGridComboBoxColumn.ElementStyle>
                                        <dg:DataGridComboBoxColumn.EditingElementStyle>
                                            <Style TargetType="ComboBox">
                                                <Setter Property="ItemsSource" Value="{Binding Path=DataContext.StatusList, 
  RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" />
                                            </Style>
                                        </dg:DataGridComboBoxColumn.EditingElementStyle>

                                    </dg:DataGridComboBoxColumn>

                                </dg:DataGrid.Columns>



                            </dg:DataGrid >
                        </StackPanel>
                    </DataTemplate>
                </dg:DataGrid.RowDetailsTemplate>
                <dg:DataGrid.Columns>
                    <dg:DataGridTextColumn Header="Name"
                                  Binding="{Binding Path=Name,ValidatesOnDataErrors=True,Mode=TwoWay}" Width="150" EditingElementStyle="{StaticResource CellEditStyle}" />
                </dg:DataGrid.Columns>
            </dg:DataGrid >


Apr 29, 2009 at 4:15 PM
It appears that the parent row receives the same SelectionChanged event as the child combobox.   Using the JanRelease, there is a workaround that includes canceling the ParentEvent and allowing the ChildEvent to continue. (Thanks Mahender for finding that solution!)

It appears that this is addressed as a bug fix in the March2009 release, however.   Does anyone know which bug is related to this issue (which work item?)

Also, is there a full list of release note for the March09 wpftoolkit?  I used the advanced search on issue tracker an didn't see any associated with the March Release.

Tracy