c# - How can you programatically scroll a WrapGrid to a specific item within its ItemSource in a Windows Store App? -
i have following:
<gridview.itemspanel> <itemspaneltemplate> <wrapgrid orientation="vertical" maximumrowsorcolumns="10" /> </itemspaneltemplate> </gridview.itemspanel>
i scroll specific item, can't find out how.
so far have:
int itemindex = ...; var scrollbar = thegridview.getfirstdescendantoftype<scrollviewer>(); scrollbar.scrolltohorizontaloffset((double)itemindex / numberrows);
... feels oddly hacky, , means have programatically calculate number of rows.
const int individualitemheight = /* nasty hard-coded thing */; numberofrows = (int)((thegridview.actualheight - thegridview.padding.top - thegridview.padding.bottom) / individualitemheight);
... more hacky.
there must better way. appreciated!
to scroll specific view gridview need access object bind grid view item , invoke listviewbase.scrollintoview(object)
Comments
Post a Comment