views:

514

answers:

1

I have a datagrid in silverlight with child datagrid nested in it. Also I have a DataPager on the outer datagrid. The code looks like this:

<data:DataGrid x:Name="dgData"  Width="600" ItemsSource="{Binding}" AutoGenerateColumns="False" IsReadOnly="True"
                       HorizontalScrollBarVisibility="Hidden" CanUserSortColumns="False" RowDetailsVisibilityChanged="dgData_RowDetailsVisibilityChanged" Margin="20,0" Grid.RowSpan="2">
                <data:DataGrid.Columns>
                    <data:DataGridTextColumn Header="Item" Width="*" Binding="{Binding ItemName,Mode=TwoWay}"/>
                    <data:DataGridTextColumn Header="Company" Width="*" Binding="{Binding Company,Mode=TwoWay}"/>
                </data:DataGrid.Columns>
                <data:DataGrid.RowDetailsTemplate>
                    <DataTemplate>
                        <data:DataGrid x:Name="dgRowDetail" Width="400" HorizontalScrollBarVisibility="Hidden" AutoGenerateColumns="False" Visibility="Collapsed">
                            <data:DataGrid.Columns>
                                <data:DataGridTextColumn Header="Date" Width="*" Binding="{Binding Date,Mode=TwoWay}"/>
                                <data:DataGridTextColumn Header="Price" Width="*" Binding="{Binding Price,Mode=TwoWay}"/>
                            </data:DataGrid.Columns>
                        </data:DataGrid>
                    </DataTemplate>
                </data:DataGrid.RowDetailsTemplate>
            </data:DataGrid>

            <data:DataPager x:Name="dpData" HorizontalAlignment="Center" DisplayMode="FirstLastPreviousNextNumeric" Source="{Binding}"/>

I have one PagedCollectionView pgv which is bound to outer datagrid as:

DataContext = pgv;

When the row is clicked I set the child datagrid's ItemsSource property to another PagedCollectionView.

My problem is it works fine except for the first row for the first time. When I click on it, it doesn't fire the dgData_RowDetailsVisibilityChanged event.

Also, when I click on second row, firstly first row fires the event and then the second row fires it and shows the nested grid.

Please help.

A: 

It worked when I set the dgData.SelectedIndex = -1; for the first time use.

Archie