1

在 Windows Phone 7 应用程序中,是否可以在代码中捕获硬件相机按钮按下事件?现在,当我按下相机按钮时,什么也没有发生,我不知道如何连接到该事件。

4

1 回答 1

1

是的你可以。检查此链接。这是事件的一个示例:

// The event is fired when the shutter button receives a half press.
CameraButtons.ShutterKeyHalfPressed += OnButtonHalfPress;

// The event is fired when the shutter button receives a full press.
CameraButtons.ShutterKeyPressed += OnButtonFullPress;

// The event is fired when the shutter button is released.
CameraButtons.ShutterKeyReleased += OnButtonRelease;

// Provide auto-focus with a half button press using the hardware shutter button.
private void OnButtonHalfPress(object sender, EventArgs e)
{
        if (cam != null)
        {
            // Focus when a capture is not in progress.
            try
            {
                this.Dispatcher.BeginInvoke(delegate()
                {
                    txtDebug.Text = "Half Button Press: Auto Focus";
                });

                cam.Focus();
            }
            catch (Exception focusError)
            {
                // Cannot focus when a capture is in progress.
                this.Dispatcher.BeginInvoke(delegate()
                {
                    txtDebug.Text = focusError.Message;
                });
            }
        }
    }
于 2012-08-15T17:23:14.613 回答