2011-03-02 86 views
2


在我的應用我做了這個映射我的app.xaml.cs URI,現在的事情是,如果我的應用程序停用在MainPage.xaml中,而不是Eula.xaml我的應用程序退出。否則,該應用會在其啓動的同一頁面上退出。 在App.xaml中Windows Phone 7後退按鈕和應用程序墓碑?

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

請指引我一樣。

Regards,

Panache。

+0

UriMappers並非意在以這種方式使用。你究竟在努力實現什麼? – 2011-03-03 09:32:19

+0

@馬特萊西,我試圖啓動一次我EULA.xaml頁面時,應用程序是首次推出,有後,我要開始我的MainPage.xaml中的應用程序,我得到這個功能,但是按照認證準則的應用程序應它開始在頁面上退出右它就像明智的,但如果我的應用程序墓碑後退導航的行爲就像Mainpage-> FirstPage->退出應該是這樣MainPage-> EULA->退出。謝謝.. – Panache 2011-03-03 10:44:09

+0

@馬特萊西,http://stackoverflow.com/questions/4463085/how-to-navigate-eula-and-mainpage – Panache 2011-03-03 10:50:48

回答

0

我建議,而不是一個整體單獨的頁面(如你已經注意到這中斷導航),只要把含在頭版不可見的EULA網格或用戶控件。當用戶第一次打開頁面時,顯示grid/usercontrol,但在後續運行時,您不會。

<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; 

} 
相關問題