I'm working on a UWP application (first time developer) and am facing the following issue.
I've a MainPage.xaml and a frame residing in it. The top section (containing menu and the header section) is required in all the pages, so I decided to use a frame beneath it and load all the pages within the MainPage.xaml
this text changes event takes place on the menu selection change event which is fired from the main page, as well as the pages on the frame (when navigating from childPage1 to childPage2).
The problem I'm facing is that, that the Header in the MainPage.xaml is supposed to be changed according to the page that is loading in the frame, but is not happening when I go from childPage1 to childPage2.
When a new page is loaded in the frame from the menu present in the Mainpage.xaml, it changes as desired, but from childPage1's click/tap event, the text doesn't change.
Please help me, as I'm doing something wrong while doing it from childPage1.
What I have tried:
I've created a function (let's say: changeHeader) in a different class in order to call that function whenever necessary.
I've modified the scope of the textblock to public in order to access it in the changeHeader class.
The code in the class file is small and as follows:
MainPage objMainPage = new MainPage();
objMainPage.txtHeader.Text = "New Header";