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.

  1. expose instance of mainpage static in mainpage.cs
  2. pass mainpage (this pointer) each frame when navigate there
  3. 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

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -