我正在创建一个小型测试相机应用程序,我希望能够实现一个功能,当硬件相机按钮被按下一半时,允许焦点文本栏出现在屏幕上。我创建了一个 camera_ButtonHalfPress 事件来执行焦点操作,但我不确定如何相应地切换我想在屏幕上显示的文本栏。本质上,我的目标是在半按相机按钮时显示文本栏,然后在完全按下按钮或在完全按下之前释放按钮时将其删除。被释放的按钮是我遇到问题的部分。我所拥有的如下:
MainPage.xaml.cs
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
...
//Event is fired when the button is half pressed
CameraButtons.ShutterKeyHalfPressed += camera_ButtonHalfPress;
//Event is fired when the button is fully pressed
CameraButtons.ShutterKeyPressed += camera_ButtonFullPress;
}
private void camera_ButtonHalfPress(object sender, EventArgs e)
{
//camera.Focus();
// Show the focus brackets.
focusBrackets.Visibility = Visibility.Visible;
}
}
private void camera_ButtonFullPress(object sender, EventArgs e)
{
// Hide the focus brackets.
focusBrackets.Visibility = Visibility.Collapsed;
camera.CaptureImage();
}
}
目前,如果用户决定在完全按下相机按钮之前释放它,则焦点括号会保留在屏幕上。我该如何解决这个问题?