Q:

WPF call method from MainWindow not working

I have the following classes:
MainWindow:
public partial class MainWindow : Window
{

    public MainWindow()
    {
        InitializeComponent();
        MainMenu mainMenu = new MainMenu(this);
        menuFrame.Navigate(mainMenu);
        UserPage userP = new UserPage();
        contentFrame.Navigate(userP);
    }

    public void LoadAPage(Page page)
    {
        contentFrame.Navigate(page);
    }
}

MainMenu:
public partial class MainMenu : Window
{
    private Window switchPage;

    public MainMenu(MainWindow mainP)
    {
        Window mainWindow = mainP;
        InitializeComponent();
        switchPage = mainP;
    }

    private void btn_navigate_user(object sender, EventArgs e)
    {
        UserPage userP = new UserPage(ServiceLogic);

        //switchPage = Window.GetWindow(PageSwitcher);
        //switchPage.LoadAPage(new UserPage());
    }

As you can see, I'm trying to use the LoadAPage-method from the MainWindow. The MainMenu and UserPage are childs from the MainWindow. The problem is, no matter what I try, I cannot reach the LoadAPage method. I've tried setting the Owner but that doesn't work. When trying mainMenu.Owner = this;, Visual Studio says Mainmenu does not contain a definition for 'Owner``. When I give the parent class as a  parameter to the child class, there are no errors but the methodLoadAPage` is unknown there.
What am I doing wrong? How should I solve this?
EDIT: Changing MainMenu to a Window instead of UserControl makes me able to set the Owner. Still, I can't reach the method.

A:

What a mess :) Try this
private MainWindow switchPage;

public MainMenu(MainWindow mainP)
{
    InitializeComponent();
    switchPage = mainP;
}

private void btn_navigate_user(object sender, EventArgs e)
{
    UserPage userP = new UserPage(ServiceLogic);
    switchPage.LoadAPage(userP);
}

However i think you ll be better off using events, instead of passing your window object to its childs.

