2013-06-16 4 views
5

私はアプリを持っていて、RootFrameが最初に初期化されたときに初めてアプリが起動されたかどうかを確認しています。そうであれば、RootFrame UriMapperをチュートリアルページに変更します。問題は、ユーザーをMainPage.xamlにリダイレクトする方法を見つけられないようです。それはこれまで何もしません。Windows Phone 8でUriMapperを変更した後リダイレクトページ

if (App.Model.SelectFirstStart()) 
{ 
    var mapper = new UriMapper(); 

    mapper.UriMappings.Add(new UriMapping 
    { 
     Uri = new Uri("/MainPage.xaml", UriKind.Relative), 
     MappedUri = new Uri("/TutorialPage.xaml", UriKind.Relative) 
     }); 

     RootFrame.UriMapper = mapper; 
    } 

ユーザーはチュートリアルページでボタンをタップすると、それはメインページにリダイレクトする必要があります

これは私がアプリのコンストラクタで初期スタートアップページを変更するために使用しているコードです。 xaml。

NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative)); 

そして:

App.RootFrame.Navigate(new Uri("/MainPage.xaml", UriKind.Relative)); 

をすべてのヘルプははるかに高く評価されるだろうこれは私がこれまで試したものです。ありがとうございます

答えて

6

私はいくつかの問題を参照してください。

まず、チュートリアルページでマッピングを変更していないので、基本的にMainPage.xamlTutorialPage.xamlにマップされます。

第二の問題は、さらにMainPage.xamlへのナビゲーションはまだTutorialPage.xamlされている実際のページにもかかわらず、理由は動作しません、という固定した後、RootFrame.CurrentSourceはまだどんなMainPage.xamlを指していないだろうさ。あなたはそれを修正チュートリアル・ページのボタンをクリック

// Inside the Button click event of TutorialPage.xaml 
// Change the mapping so that MainPage points to itself 
((UriMapper)App.RootFrame.UriMapper).UriMappings[0].MappedUri = 
    new Uri("/MainPage.xaml", UriKind.Relative); 

// Since RootFrame.CurrentSource is still set to MainPage, you need to pass 
// some dummy query string to force the navigation 
App.RootFrame.Navigate(new Uri("/MainPage.xaml?dummy=1", UriKind.Relative)); 

// Remove back entry so that if user taps the back button 
// you won't get back to tutorial 
App.RootFrame.RemoveBackEntry(); 
+0

で次の操作を行う必要があり、この問題を解決するには

は、どうもありがとうございました。私は前にそれを再マッピングしようとしましたが、私はバックエントリを削除する必要があったことを認識していませんでした。再度、感謝します! – user1186173

関連する問題