【问题标题】:Windows Phone 7 Back button and application Tombstone?Windows Phone 7 后退按钮和应用程序墓碑?
【发布时间】:2011-03-10 06:09:02
【问题描述】:


在我的应用程序中,我这样做是为了在 app.xaml.cs 中映射我的 uri,现在的问题是,如果我的应用程序在 MainPage.xaml 而不是 Eula.xaml 上停用我的应用程序退出。否则,应用程序将在其启动的同一页面上退出。 在 App.xaml 中

<UriMapper:UriMapper x:Name="mapper">
<UriMapper:UriMapping Uri="/MainPageOrEULA.xaml"/>
</UriMapper:UriMapper>

在 App.xaml.cs 中

// Get the UriMapper from the app.xaml resources, and assign it to the root frame
UriMapper mapper = Resources["mapper"] as UriMapper;
RootFrame.UriMapper = mapper;

// Update the mapper as appropriate
IsolatedStorageFile isoStorage = IsolatedStorageFile.GetUserStoreForApplication();
if (isoStorage.FileExists("DataBase/MyPhoneNumber.txt"))
{
    mapper.UriMappings[0].MappedUri = new Uri("/MainPage.xaml", UriKind.Relative);
}
else
{
    mapper.UriMappings[0].MappedUri = new Uri("/EULA.xaml", UriKind.Relative);
}

请指导我。

问候,

华丽。

【问题讨论】:

  • UriMappers 不打算以这种方式使用。你到底想达到什么目的?
  • @Matt Lacey,我正在尝试在第一次启动应用程序时启动我的 EULA.xaml 页面,并且在我想从 MainPage.xaml 启动我的应用程序之后,我得到了这个功能,但是根据认证指南,应用程序应该在正确启动的页面上退出,它的工作方式很明智,但是如果我的应用程序墓碑,则后退导航的行为类似于 Mainpage->FirstPage->Exit,它应该类似于 MainPage->EULA->Exit。谢谢..

标签: windows-phone-7


【解决方案1】:

我建议不要有一个完整的单独页面(您已经注意到这会中断导航),而只需在不可见的首页上放置一个包含 EULA 的网格或用户控件。当用户第一次打开页面时,您会显示网格/用户控件,但在随后的运行中,您不会。

<Grid x:Name="LayoutRoot">

    <Grid Name="EULA" Visibility="Collapsed" >
        <TextBlock Text = "You agree ...." />
        <Button Grid.Row="1" Content="I Agree" Click="AgreeClick" />
    </Grid>

    <Grid Name="MainGrid" >
    ....

然后在你后面的代码中你可以将你的测试添加到加载的事件中

private void MainPageLoaded()
{
    IsolatedStorageFile isoStorage = IsolatedStorageFile.GetUserStoreForApplication();
    if (!isoStorage.FileExists("DataBase/MyPhoneNumber.txt"))
    {
        EULA.Visibility = Visibility.Visible;
        MainGrid.Visibility = Visibility.Collapsed;
    }
}

然后当点击“我同意”按钮时,您可以存储文件并显示主网格

private void AgreeClick(....)
{
    // Create isolated storage file
    ....

    // Hide eula control
    EULA.Visibility = Visibility.Collapsed;
    MainGrid.Visibility = Visibility.Visible;

}   

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-08-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多