c# - Navigating one frame from within a second frame not working -
my mainpage has 2 frames. can navigate both frames mainpage. want navigate secondframe page within firstframe. code runs fine, frame doesn't navigate. thanks.
mainpage.xaml
<splitview.content> <grid> <grid.rowdefinitions> <rowdefinition height="*" /> <rowdefinition height="auto" /> </grid.rowdefinitions> <grid.columndefinitions> <columndefinition width="*" /> <columndefinition width="300" /> </grid.columndefinitions> <frame x:name="firstframe" horizontalalignment="stretch" grid.row="0" grid.column="0" /> <frame x:name="secondframe" grid.row="0" grid.column="1" borderbrush="lightblue" borderthickness="1,0,0,0" /> </grid> </splitview.content> mainpage.xaml.cs
public void setsecondframe() { secondframe.navigate(typeof(input)); } calendar.xaml.cs
private void selecteddate_click(object sender, routedeventargs e) { mainpage mp = new mainpage(); mp.setsecondframe(); } it works fine if call within mainpage, not when call calendar page.
thanks
the issue call new mainpage(). creates whole new page rather using existing mainpage instance , driving click handler.
you have different options chose from, , have decide works you.
- expose instance of mainpage static in mainpage.cs
- pass mainpage (this pointer) each frame when navigate there
- variations on these ideas
for simplicity, maybe #1 easiest.
in class, create public static mainpage instance {get; private set;}
in mainpage(), assign instance = this;
from other page want use mainpage like:
app.mainpage.instance.setsecondframe()
you may have tweak above per exact project settings/names.
Comments
Post a Comment