简体   繁体   English

从框架导航到MainPage

[英]Navigate to MainPage from Frame

Current Position: MainPage -> MainPageFrame -> FramePageFrame -> 当前位置:MainPage-> MainPageFrame-> FramePageFrame->

Trying to use the following code from within the FramePageFrame: 尝试在FramePageFrame中使用以下代码:

    private void Button_Click(object sender, RoutedEventArgs e)
    {
       var page = (MainPage)Window.Current.Content;             
       page.MainFrame.Navigate(typeof(MainPage));
    }

MainPage: 主页:

    public Frame MainFrame
    {
        get { return this.frameContent; }
    }

The code takes me back to the main page, but then it also seems to load MainPage again inside of the frameContent. 该代码将我带回到主页,但随后它似乎在frameContent内再次加载MainPage。

Ideas? 想法?

Fixed it by changing 通过更改进行修复

page.MainFrame.Navigate(typeof(MainPage));

to

page.MainFrame.Navigate(typeof(Command)); 
// Command is another page I want to load after returning to MainPage

Calling Navigate on a Frame control not only takes a user to that page, but also navigates the frame (apparently). 在“框架”控件上调用“ Navigate ”不仅可以将用户带到该页面,还可以(显然)导航框架。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM