博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
GridView.ScrollIntoView() doesn't work
阅读量:5339 次
发布时间:2019-06-15

本文共 2232 字,大约阅读时间需要 7 分钟。

I am writing an application which contains two pages, GroupedItemsPage and ItemDetailPage. I let lots of pictures present in the GroupItemsPage, then after select a specified picture in this page, it will nevigate the the second page withe the details showing for the selected picture. Since I put too much pictures in the first page, therefore the gridview always put the top picutres into view each time I goback to the first page. even the picture I selected previously are the last picture which need a scroll to the end.

 

I tried to use GridView.ScrollIntoView() in the LoadState method, my codes like below.

protected override void LoadState(Object navigationParameter, Dictionary
pageState) { // TODO: Create an appropriate data model for your problem domain to replace the sample data var sampleDataGroups = SampleDataSource.GetGroups((String)navigationParameter); this.DefaultViewModel["Groups"] = sampleDataGroups; if (pageState!=null&&pageState.ContainsKey("SelectedItem")) { SelectedItemId = pageState["SelectedItem"].ToString (); var sampleDataItem = SampleDataSource.GetItem(SelectedItemId); //SampleDataGroup group = ((SampleDataItem)sampleDataItem).Group; //groupedItemsViewSource.View.MoveCurrentTo(group); itemGridView.ScrollIntoView(sampleDataItem); } }

however, nomatter what I do, it just doesn't work.

 

then I moved the method call to Loaded event like below. It works:

public GroupedItemsPage()        {            this.InitializeComponent();            Loaded += GroupedItemsPage_Loaded;        }        void GroupedItemsPage_Loaded(object sender, RoutedEventArgs e)        {            if (SelectedItemId!=null&&SelectedItemId != string.Empty)            {                var sampleDataItem = SampleDataSource.GetItem(SelectedItemId);                //SampleDataGroup group = ((SampleDataItem)sampleDataItem).Group;                //groupedItemsViewSource.View.MoveCurrentTo(group);                itemGridView.ScrollIntoView(sampleDataItem);                }        }

 

转载于:https://www.cnblogs.com/qixue/archive/2012/12/15/2818967.html

你可能感兴趣的文章
Centos6.9下安装OpenOffice 4.1.4
查看>>
oracle 创建用户 导入备份数据
查看>>
教大家使用Python SqlAlchemy- 51jb
查看>>
009 微服务容错机制
查看>>
vue的安装以及语法介绍
查看>>
【学习笔记】慕课网—Java设计模式精讲 第3章 软件设计七大原则-3-2 开闭原则...
查看>>
实时检测网络状态及是否可以连接Internet
查看>>
浅谈 qmake 之 pro、pri、prf、prl文件
查看>>
F WebDriver and 环境配置
查看>>
使用思维导图编写用例
查看>>
图标名称大写导致R cannot&nb… 分类: A...
查看>>
Error: [WinError 10013] 以一种访问权限不允许的方式做了一个访问套接字的尝试。...
查看>>
SpringMVC 拦截器简单配置
查看>>
第一次作业小结
查看>>
erlang http post 发送数据请求
查看>>
Unresolved external CheckAutoResult
查看>>
[收藏转贴]struct探索·extern "C"含义探索 ·C++与C的混合编程·C 语言高效编程的几招...
查看>>
tinkcmf视频上传大小限制
查看>>
《第1章:统计学习方法概论》
查看>>
JS定时器时间日期钟表
查看>>