c# - The state-preserving dictionary isn't preserving state -
i have followed tutorial here preserve state between pages.
however, state dictionary empty, when programatically navigate page! seems problem here?
i have tested behaviour on emulator 8.0.10322 720p.
this do:
protected override void onnavigatedfrom(navigationeventargs e) { base.onnavigatedfrom(e); if (e.navigationmode != navigationmode.back) { state["is"] = resultslist.itemssource; state["si"] = resultslist.selecteditem; state["dgtest"] = new data(); state["test"] = "gi2"; } } protected override void onnavigatedto(navigationeventargs e) { base.onnavigatedto(e); if (e.isnavigationinitiator && e.navigationmode != navigationmode.back) { resultslist.itemssource = (system.collections.ilist) state["is"]; resultslist.selecteditem = state["si"]; } }
the objects in itemssource of type data, defined here:
[datacontract] public class data { [datamember] public string datum { get; set; } }
edit: programatically navigate back, i'm calling navigationservice.navigate(new uri("/mypages/page.xaml", urikind.relative));
Comments
Post a Comment