silverlight 4 中的 Datapager - 嵌套数据网格可见性问题
我有一个 silverlight 数据网格,其中嵌套有子数据网格。另外,我在外部数据网格上有一个 DataPager
。 代码如下所示:
<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}"/>
我有一个 PagedCollectionView
pgv,它绑定到外部数据网格,如下所示:
DataContext = pgv;
单击该行时,我将子数据网格的 ItemsSource 属性设置为另一个 PagedCollectionView
。
我的问题是,除了第一次的第一行之外,它工作正常。当我单击它时,它不会触发 dgData_RowDetailsVisibilityChanged 事件。
另外,当我单击第二行时,首先第一行触发事件,然后第二行触发它并显示嵌套网格。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当我第一次使用时设置
dgData.SelectedIndex = -1;
时它起作用了。It worked when I set the
dgData.SelectedIndex = -1;
for the first time use.