Call function from another class

Hello, I have a program written in C++/XAML where if you click a button, the settings page will appear (by setting a frame's visibility to visible). On the settings page, the back button will collapse the frame. The frame is on the MainPage, the code that handles the back button click is on SettingsPage, how do I call the MainPage method? The below does not work.

MainPage:
1
2
3
4
void MainPage::SettingsBackButtonClick()
{
    SettingsHolder->Visibility = ::Visibility::Collapsed;
}


SettingsPage:
1
2
3
4
5
void SettingsPage::BackButton_Click(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e)
{
    MainPage mainPage;
    mainPage.SettingsBackButtonClick();
}
Last edited on
You actuall need to pass the pointer of the MainPage to the SettingsPage. Preferable in the constructor of SettingsPage or later with a function.
Topic archived. No new replies allowed.