问题描述
是否可以滚动到Silverlight中的特定行(按对象标识)有一个 which是。
Is it possible to scroll to a particular row (by object identity) in a Silverlight DataGrid
that has an ItemsSource
which is a PagedCollectionView
.
我正在加载按天/状态等分组的订单列表。我需要能够滚动到一个特定的顺序。
I am loading a list of orders that are grouped by day/status etc. I need to be able to scroll to a particular order.
var pcv = new PagedCollectionView(e.Result.Orders);
gridOrders.ItemsSource = pcv;
不幸的是,因为。
Unfortunately, ScrollIntoView(order)
doesn't work because of the PagedCollectionView
.
显示可以滚动到,但这并没有太多的用处。
An article on DataGrid from MSDN shows that it is possible to scroll to a group in a PagedCollectionView
, but that's not really much use.
foreach (CollectionViewGroup group in pcv.Groups)
{
dataGrid1.ScrollIntoView(group, null);
dataGrid1.CollapseRowGroup(group, true);
}
有没有办法呢?
推荐答案
是的,当项目源是,否则调用直接从事件处理程序调用时会失败(可能是因为未正确更新其处理事件的状态。此方法可确保当前事件处理在调用滚动之前正确完成。
I used BeginInvoke
because otherwise, the call to ScrollIntoView
would fail when called directly from an event handler (presumably because the DataGrid
hadn't properly updated its state for the event being handled). This approach ensures that the current event handling completes properly before invoking the scroll.
这篇关于您可以在Silverlight DataGrid中使用ScrollIntoView()与PagedCollectionView吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!