I want to Pass data to a another page that will be displayed on the Detail View of a MasterDetailPag

PaulaAliuPaulaAliu USMember ✭✭

Hi,
I have a MasterDetail Page that serves as a Navigation Menu for my App (ie it navigates between MainPage to settings to aboutUs Page etc), the Master Page houses a list of the Pages. When I select an item from the list, The Detail page provides me with the Page in Question. Now I have a page that creates an instance of a object, i want to pass this created object to the mainpage and add it to the mainpage's observablecollection of objects. This implies I want to change the detailpage current content from the creating page to the mainpage, How do I go about this. Thank you.

Answers

  • AdrianKnightAdrianKnight USMember ✭✭✭✭

    You can store objects globally in App.cs or use MessagingCenter to send a message from a page to the mainpage. If you use MVVM, these things are somewhat more trivial.

    Here's your workflow:
    1) create your object
    2) store it in a variable in App.cs
    3) inside OnAppearing of your mainpage, check to see if the data is in App.cs
    4) add it to your collection

    MessagingCenter is more direct as in it zaps you from one place to another.

Sign In or Register to comment.