c# - How to navigate to specifically position on ListBox Windows Phone 8.1 -
i have listbox lot of items, , each items when clicked go new page, want when return second page, stay @ same position of item clicked!
thats list!
<listbox x:name="list" loaded="listview_loaded" selecteditem="true" selectionchanged="searchresultslist_selectionchanged" itemssource="{binding}" background="{x:null}"> <!--<listview.itemcontainerstyle> <style targettype="listviewitem"> <setter property="horizontalcontentalignment" value="stretch"/> <setter property="margin" value="0,0,0,15" /> </style> </listview.itemcontainerstyle>--> <listbox.itemtemplate> <datatemplate> <grid> <grid.columndefinitions> <columndefinition width="80" /> <columndefinition width="10" /> <columndefinition width="*" /> </grid.columndefinitions> <border width="80" height="80"> <image source="{binding caminho}" /> </border> <stackpanel margin="0,16,0,0" grid.column="2"> <textblock foreground="white" text="{binding nomecurso}" textwrapping="wrap" fontsize="{staticresource textstyleextralargefontsize}" /> </stackpanel> </grid> </datatemplate> </listbox.itemtemplate> </listbox>
thanks!
if using winrt can write following code in page constructor cache it, way positions intact after go page:
this.navigationcachemode = navigationcachemode.required;
and sample cant see if using listbox
or listview
, presume listview
better listbox
not needed anymore.
one thing noticed use simple {binding}
itemssource
maybe reset every time go because of (if doing this, not visible sample code). have additional property of type observablecollection
, bind example itemssource={binding myitems}
. way list reset when reset property myitems
.
Comments
Post a Comment