I need some help. I have a 2 pages in my app. Page #1 with 3 buttons.
Button #1 = the name is "amount" and the content is "blank".
Button #2 = the name is "tips" and the content is "blank".
Button #3 = the name is "split" and the content is "blank".
When I click in any of the buttons, the app navigates to page #2.
In page #2, I want to enter some values, store the value into IsolatedStorageSettings, then retrive it in Page #1 and display the value in the content of the button that was pressed.
Ex: Button #3 was pressed. In Page #2 I enter some values and store the value to “SplitAmount” file in IsolatedStorageSettings. Now in Page #1 I want to retrieve the value and display it as the content for the button #3.
Question: How can I make the app knows which button was pressed, so I can store the value to the right file in IsolatedStorageSettings without the need to create a page for each button?
PS: I hope I explain myself clear enough, plus I’m still a noob. Take it easy on me.
Create one
Clickevent handler and assign it to all three buttons. Then pass the name of the clicked button as parameter to page #2.The click handler looks like this:
Assign this handler to the Click event of all three buttons. You can use the Properties window of Visual Studio to do this. Look at the code how the handler dynamically gets the button name from its
senderand appends it to the Uri string as parameterbuttonName.When the user clicks any of the buttons the handler is invoked and navigates to
Page2.xaml. Assume we want to access thebuttonNameright when the page opens. To do this you override theOnNavigatedTomethod:The passed parameter can be accessed via the
QueryStringdictionary. The code checks if the entrybuttonNameexists. If it does it displays a message box.Of course you can get your
buttonNameat any later time, no need to overrideOnNavigatedTo. You probably would read it later when you save data to isolated storage.