c# - How to refresh the current page after selecting an item in ListPicker -
i'd know how refresh current page with
henavigationservice.navigate(new uri(navigationservice.source + "?refresh=true", urikind.relative));
after pick element in listpicker.
i suppose using mvvm light windows phone. in case, should catch event in page , trigger command on viewmodel.
example:
code-behind of page
private void listbox_selectionchanged(object sender, selectionchangedeventargs e) { viewmodelclass vm = this.datacontext viewmoedlclass; if (vm != null) { vm.refreshcommand.execute(); } }
viewmodel
class viewmodelclass { public viewmodelclass { this.refreshcommand = new relaycommand(() => { navigationservice.navigate(new uri(navigationservice.source + "?refresh=true", urikind.relative)); } } public relaycommand refreshcommand { get; set;} }
xaml
<listbox selectionchanged="listbox_selectionchanged" />
in theory shouldn't have in code-behind , bind command viewmodel directly selectionchanged-event, not (directly) possible in windows phone. if want go route can take @ eventtocommand. page explains steps in more detail: http://www.geekchamp.com/articles/how-to-bind-a-windows-phone-control-event-to-a-command-using-mvvm-light
Comments
Post a Comment