c# - Universal windows app to send data from one page to another -
i had partitioned mainpage.xaml
in 2 parts. left part has buttons give command change right part new page. created 3 right pages ex. rightpage1
, rightpage2
, rightpage3
. problem that, want show data on left part after operations done on rightpage1
, 2 or 3. should follow pattern fulfill approach? or can directly in code behind?
all researched giving me solution navigate page , send data in parameter. don't want open page again, because it's opened on left side of mainpage
. please me solve situation.
in rightpage 1, on submit click event want show message in mainpage.xaml
's left part in textblock
lblclassname.
homepage.xaml <grid> <grid.columndefinitions> <columndefinition width="5*"/> <columndefinition width="3*"/> </grid.columndefinitions> <relativepanel> <button x:name="btn1" content="button 1" height="50" width="100" margin="0,30,0,0" relativepanel.alignhorizontalcenterwithpanel="true" click="btn1_click"/> <button x:name="btn2" content="button 2" height="50" width="100" margin="0,30,0,0" relativepanel.alignhorizontalcenterwithpanel="true" relativepanel.below="btn1" click="btn2_click"/> <button x:name="btn3" content="button 3" height="50" width="100" margin="0,30,0,0" relativepanel.alignhorizontalcenterwithpanel="true" relativepanel.below="btn2" click="btn3_click"/> <textblock x:name="lblwrite" text="write : " visibility="visible" relativepanel.below="btn3"/> <textbox x:name="txtwrite" height="50" width="150" visibility="collapsed" relativepanel.below="lblwrite"/> <button x:name="btn3_1" height="50" width="100" visibility="collapsed" content="send" relativepanel.below="txtwrite"/> <textblock x:name="lblclassname"/> </relativepanel> <frame x:name="rightpage" grid.column="1"/> </grid> rightpage1.xaml <grid background="beige"> <textblock x:name="heading" text="teacher module" relativepanel.alignhorizontalcenterwithpanel="true"/> <textblock x:name="lblname" text="name" margin="0,30,0,0" relativepanel.alignhorizontalcenterwithpanel="true" relativepanel.below="heading"/> <textbox x:name="txtname" height="30" width="150" margin="30,30,0,0" relativepanel.rightof="lblname" relativepanel.below="heading"/> <textblock x:name="lblclass" text="class" margin="0,30,0,0" relativepanel.alignhorizontalcenterwithpanel="true" relativepanel.below="lblname"/> <textbox x:name="txtclass" height="30" width="150" margin="30,10,0,0" relativepanel.rightof="lblclass" relativepanel.below="txtname"/> <button x:name="btnsumbit" content="submit" height="50" width="100" margin="0,30,0,0" relativepanel.alignhorizontalcenterwithpanel="true" relativepanel.below="lblclass"/> <button x:name="btncancel" content="cancel" height="50" width="100" margin="30,30,0,0" relativepanel.alignhorizontalcenterwithpanel="true" relativepanel.below="lblclass" relativepanel.rightof="btnsumbit"/> <textblock x:name="lblresult" margin="0,30,0,0" relativepanel.below="btnsumbit"/> </relativepanel> </grid>
i think can directly in code behind. example:
in code-behind of homepage.xaml, can define static field in homepage
represent homepage
, add public method change textblock
's text.
public sealed partial class homepage : page { //define static field represent homepage public static homepage home; public homepage() { this.initializecomponent(); //initialize home field home = this; } ... /// <summary> /// show message in textblock lblclassname /// </summary> /// <param name="message">message been shown</param> public void changemessage(string message) { this.lblclassname.text = message; } }
then in submit click event, can call changemessage
method show message.
private void btnsumbit_click(object sender, routedeventargs e) { homepage.home?.changemessage("the message want show"); }
Comments
Post a Comment