开发者

Windows Phone 7 Back button and application Tombstone?

In my application i had done this to map my uri in app.xaml.cs, now the thing is if my application deactivates my application exits on MainPage.xaml rather than Eula.xaml. Else the app exits on the same page on which it starts. In App.xaml

<UriMapper:UriMapper x:Name="mapper">
<UriMapper:UriMapping Uri="/MainPageOrEULA.xaml"/>
&l开发者_如何转开发t;/UriMapper:UriMapper>

and in 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);
}

Please guide me for the same.

Regards,

Panache.


I suggest that rather than having a whole separate page (which interrupts navigation as you've noticed), just put a grid or usercontrol containing the EULA on the front page that isn't visible. When the user first opens the page, you show the grid/usercontrol, but on subsequent runs, you don't.

<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" >
    ....

Then in your code behind you can add your test to the loaded event

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

Then when the "I agree" button is clicked you can store the file and show the main grid

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

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

}   
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜