在一个Windows Phone 7的应用程序,是能够捕捉代码按下事件的硬件相机按钮? 现在,当我按下相机按钮什么也没有发生,我无法弄清楚如何挂钩的事件。
Answer 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;
});
}
}
}
文章来源: Wp7 Camera Button Event