简体   繁体   中英

Windows Store App frame.navigate() not working

So, basically I have 2 pages: "MainPage.xaml" and "Workpage.xaml" . I Created a button for navigation from MainPage to WorkPage and it doesn't work... Why would that be? It works normally in my Windows Phone App...

<Page
x:Class="WindowsApp.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:WindowsApp"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Button x:Name="btnWorkPage" Content="Button" HorizontalAlignment="Left" Margin="580,304,0,0" VerticalAlignment="Top" Height="74" Width="208" Click="btnWorkPage_Click"/>
</Grid>

Mainpage.xaml.cs:

public sealed partial class MainPage : Page
{
    public MainPage()
    {
        this.InitializeComponent();

    }

    private void btnWorkPage_Click(object sender, RoutedEventArgs e)
    {
        Frame.Navigate(typeof(WorkPage));
    }
}

a short DEMO: http://screencast.com/t/imblOyj5CH ...

Well Seems there is some strange logic where you have to delete the MainPage and add a new one, here is some guide from MS

https://msdn.microsoft.com/en-us/library/windows/apps/hh986965.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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