Windows应用商店应用frame.navigate()无法正常工作

时间:2015-02-07 21:22:14

标签: c# xaml windows-store-apps

所以,基本上我有2个页面:“MainPage.xaml”和“Workpage.xaml”。我创建了一个从MainPage导航到WorkPage的按钮,它不起作用......为什么会这样?它在我的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));
    }
}

简短的DEMO:http://screencast.com/t/imblOyj5CH ......

1 个答案:

答案 0 :(得分:0)

好吧似乎有一些奇怪的逻辑,你必须删除MainPage并添加一个新的,这里是MS的一些指南

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