windows phone 7 - How do I create a dynamic page based on a selection? -
i trying dynamically fill second panorama page based on item selected home application screen.
on application's first start screen there listbox if items each text. if user taps on item text "foobar" template page should load , title of template page should set "foobar" , second panorama page should know it's data should related "foobar".
is there anyway this?
i have mainpage navigate new page (dynamicpage.xaml). navigation triggered when listbox_selectionchanged event occurs. have title text of dynampicpage.xaml binding titletext variable located in mainpage.xaml.cs. however, when title of dynamicpage.xaml ever set initialization value titletext variable though updating variable right before navigate page.
if can provide grateful beginner on wp7 platform. thanks!
the binding you're using title going update if titletext property dependency property or if mainpage implementing inotifypropertychanged interface class can notify ui when 1 of properties changed.
http://windowsphonegeek.com/articles/all-about-dependency-properties-in-silverlight-for-wp7
http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged(v=vs.95).aspx
but think not best way achieve this. better way store data somewhere in static class, in main page's constructor load these data listbox, , when user selected item, navigate user second page this:
navigationservice.navigate(new uri("/dynamicpage.xaml?item=" + selecteditem.id, urikind.relative));
when navigate new instance of dynamicpage created, , in onnavigatedto method can access navigation parameters , populate page selected data. example:
<controls:panorama x:name="mypanorama" title="titlehere">...</controls:panorama> item selecteditem = staticdata.getitem(navigationcontext.querystring["item"]); mypanorama.title = selecteditem.name.toupper(); description.text = selecteditem.description;
this way can use secondary tiles , toast notifications directly point specific content in application.
if you're getting understand navigation should use pattern called model-view-viewmodel solve these problems bindings, trust me, easier way now.
Comments
Post a Comment