1

Windows Phone の既定のカメラ アプリケーション内でアプリケーションのレンズ タイル アイコンを押すと、アプリケーションに移動したいと考えています。CameraCaptureTask を使用して写真を撮影し、保存して MainPage に表示していますが、これは機能しています。クリック イベントで CameraCaptureTask を呼び出しているので、質問は、レンズ ピッカーでアプリケーション タイルを選択したときに、このクリック イベントにどのようにアクセスできるかということです。

App.xaml.cs

private void InitializePhoneApplication()
    {
        if (phoneApplicationInitialized)
            return;

        // Create the frame but don't set it as RootVisual yet; this allows the splash
        // screen to remain active until the application is ready to render.
        //RootFrame = new PhoneApplicationFrame();
        RootFrame = new TransitionFrame();
        RootFrame.Navigated += CompleteInitializePhoneApplication;

        // Assign the lens example URI-mapper class to the application frame.
        RootFrame.UriMapper = new LensUriMapper();

        // Handle navigation failures
        RootFrame.NavigationFailed += RootFrame_NavigationFailed;

        // Handle reset requests for clearing the backstack
        RootFrame.Navigated += CheckForResetNavigation;

        // Ensure we don't initialize again
        phoneApplicationInitialized = true;
    }

LensUriMapper.cs

class LensUriMapper : UriMapperBase
{
    private string tempUri;

    public override Uri MapUri(Uri uri)
    {
        tempUri = uri.ToString();

        // Look for a URI from the lens picker.
        if (tempUri.Contains("ViewfinderLaunch"))
        {
            // Launch as a lens, launch viewfinder screen.
            //return new Uri("/Views/MainPage.xaml", UriKind.Relative);
            return new Uri("/Views/MainPage.xaml?Viewfinder=1", UriKind.Relative);
        }
        }

        // Otherwise perform normal launch.
        return uri;
    }
}

MainPage.xaml.cs

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    if (NavigationContext.QueryString.ContainsKey("Viewfinder"))
    {
        newButton_Click(null, null);
    }
}

void newButton_Click(object sender, EventArgs e)
    {            
        _cameraTask.Show();
    }

さらに、MSDN のレンズ アプリケーション ガイドラインに記載されているように、戻るキーを押したときに既定のカメラ アプリケーションに直接戻るにはどうすればよいですか?

4

1 に答える 1

0

ViewfinderLaunch uri にパラメーターを追加できます。

return new Uri("/Views/MainPage.xaml?Viewfinder=1", UriKind.Relative);

次に、MainPage の "OnNavigatedTo" メソッドをオーバーライドして、Viewfinder パラメーターが設定されているかどうかを確認する必要があります。

if (NavigationContext.QueryString.ContainsKey("Viewfinder"))
{
    newButton_Click(null, null);
}
于 2013-08-29T03:30:26.610 に答える