0

アプリケーションに 2 つのページがあります。ナビゲーションは MainPage > EditPage > MainPage に従います。MainPage は開始ページであり、編集ページはボタンのクリック時に NavigatedTo になり、ハードウェアの戻るボタンを使用して NavigatedFrom になる場合があります。EditPage で何らかのアクションが発生した場合、ユーザーが MainPage に戻りたいときに MainPage に通知したいと思います。http://mobile.dzone.com/articles/passing-values-between-windowsを参照しましたが、それに応じて MainPage OnNavigatedTo イベントを修正する方法がわかりません。これまでのところ、私が持っているものは次のとおりです

MainPage.xaml.cs

protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        //If action in EditPage occurred, determine that here
        ??
    }

EditPage.xaml.cs

protected override void OnNavigatedFrom(NavigationEventArgs e)
    {
        base.OnNavigatedFrom(e);

        //check to see if action occurred in EditPage, and if so, inform MainPage
        if (_wasEdited == true)
        {
            MainPage mp = e.Content as MainPage;
            if (mp != null)
                mp.Parameter = true;
        }
    }
4

2 に答える 2

0

ページ間で値を渡すには、クエリ文字列またはアプリの状態変数を使用できます。ナビゲーションの区別に関する限り、NavigatedTo イベント引数の e.URI プロパティにチェックを入れるだけです。

于 2013-09-20T13:46:54.910 に答える