导航到GridView中的索引 [英] Navigate to index in GridView
问题描述
您好,
我有一个带有数据源的GridView,其中包含可能无限的项目库。 GridView只需加载所需内容即可轻松处理。我的问题是这个。如果我想快速找到以字母P开头的所有项目,我怎样才能快速导航而不滚动浏览所有内容?幸运的是,我可以知道项目的确切索引,即使它尚未加载到模型中。我需要以某种方式导航到该索引。
我已经通过以下方式实现了这个目标非常可怕:
Hi there,
I have a GridView with a datasource with a potentially infinite library of items. GridView handles this nicely by only loading what is required. My issue is this. If I want to quickly get to all my items that begin with the letter "P", how can I quickly navigate there without scrolling through everything along the way? Fortunately, I can know the exact index of the item, even though it is not yet loaded into the model. I need to somehow navigate to that index.
I have achieved this rather horribly with something along these lines:
Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Low,
async () =>
{
string letter = "N";
object item = null;
while (item == null)
{
item = this.Library.Items.FirstOrDefault(i => (i as Book).Title.StartsWith(letter));
this.Library.ScrollIntoView((item ?? this.Library.Items.LastOrDefault()));
}
});
任何想法都会很棒。
谢谢,
Dom
Any ideas would be great.
Thanks,
Dom
推荐答案
这篇关于导航到GridView中的索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!