c# - Can't navigation between xaml in frame? -
i have got issues . why did not navigate other xaml? wrong? so, trying make can navigated between 2 or more xaml in frame.
here link : https://github.com/englbach/mutiviewinrootpage
<splitview.content> <!-- onnavigatingtopage synchronize selected item in nav menu current page. onnavigatedtopage move keyboard focus first item on page after it's loaded. --> <frame x:name="appshellframe"> <frame.contenttransitions> <transitioncollection> <navigationthemetransition> <navigationthemetransition.defaultnavigationtransitioninfo> <entrancenavigationtransitioninfo /> </navigationthemetransition.defaultnavigationtransitioninfo> </navigationthemetransition> </transitioncollection> </frame.contenttransitions> </frame> </splitview.content>
public static appshell current = null; public list<navmenuitem> navlist { get; } = new list<navmenuitem>(new[] { new navmenuitem() { symbol = symbol.add, label = "add feed", destpage = typeof(rootpages), arguments = typeof(addfeedview) }, new navmenuitem() { symbol = symbol.edit, label = "edit feeds", destpage = typeof(rootpages), arguments = typeof(editfeedview) } }); public appshell() { this.initializecomponent(); current = this; } private void navmenulist_iteminvoked(object sender, listviewitem e) { navmenulist.selectedindex = -1; var item = (navmenuitem)((navmenulistview)sender).itemfromcontainer(e); if(item!=null) { appframe.navigate(typeof(rootpages), item.arguments); } }
you followed official navigation menu (xaml) sample design layout.
there 2 tiny problems in demo.
- each time items in
navmenulist
clicked,navmenulist_iteminvoked
event in appshell.xaml.cs should triggered. , in event, navigated again , againrootpages
, , pass navigation parameter(item.arguments)rootpages
appframe.navigate(typeof(rootpages), item.arguments);
, , argument destination.
you can modify code here this:
private void navmenulist_iteminvoked(object sender, listviewitem e) { //navmenulist.selectedindex = -1; var item = (navmenuitem)((navmenulistview)sender).itemfromcontainer(e); if (item != null) { //appframe.navigate(typeof(rootpages), item.arguments); if (item.destpage != null && item.destpage != this.appframe.currentsourcepagetype) { this.appframe.navigate(item.destpage, item.arguments); } } }
- then here comes second problem, said,
arguments
should navigation parameter, example, navigateaddfeedview
page , want send message "balalala", can code this:appframe.navigate(typeof(addfeedview), "balalala");
. means, confuseddestpage
,arguments
.
you can modify navlist
this:
public list<navmenuitem> navlist { get; } = new list<navmenuitem>(new[] { new navmenuitem() { symbol = symbol.add, label = "add feed", destpage = typeof(addfeedview), arguments = typeof(rootpages) }, new navmenuitem() { symbol = symbol.edit, label = "edit feeds", destpage = typeof(editfeedview), arguments = typeof(rootpages) } });
in additional, if want appframe
navigate rootpages
@ first default, can code this:
public appshell() { this.initializecomponent(); current = this; appframe.navigate(typeof(rootpages)); }
Comments
Post a Comment