0

Settings_CommandsRequestedで現在のページまたはフレームを取得するにはどうすればよいですか?設定ペインからナビゲートしたい。

4

1 に答える 1

1

現在Frameは表示しているものなので、アクセス方法を定義できます。インスタンス参照を静的フィールドとしてAppクラスに保存するか、IoCコンテナーを使用してアクセスできます。これを行う最も簡単な方法は、Appクラスに次の更新を行うことです。

sealed partial class App : Application
{
    public static Frame RootFrame { get; private set; }

    ...

    protected override void OnLaunched(LaunchActivatedEventArgs args)
    {
        Frame rootFrame = this.RootFrame = Window.Current.Content as Frame;

        // Do not repeat app initialization when the Window already has content,
        // just ensure that the window is active
        if (rootFrame == null)
        {
            // Create a Frame to act as the navigation context and navigate to the first page
            rootFrame = this.RootFrame = new Frame();
            ...

次に、電話App.RootFrameをかけてフレームを取得します。

于 2013-03-14T17:03:13.773 に答える