void b_Hold(object sender, System.Windows.Input.GestureEventArgs e)
{
MessageBoxResult result = MessageBox.Show("A", "MessageBox Example", MessageBoxButton.OKCancel);
if (result == MessageBoxResult.OK)
{
MessageBox.Show(" ....");
}
}
void b_Click(object sender, RoutedEventArgs e)
{
Button btnevent = (Button)sender;
for (int i = 0; i < (Application.Current as App).devices.Length; i++)
if (btnevent.Content.ToString() == (Application.Current as App).devices[i])
{
(Application.Current as App).selectedDevice = i;
NavigationService.Navigate(new Uri("/pages/Buttons.xaml", UriKind.Relative));
}
}
我正在处理项目,我需要将hold和click事件定义为一个按钮。问题是点击事件总是被解雇,即使我按住或单击按钮。 换句话说,当我按住按钮时,我可以禁用点击事件吗?
答案 0 :(得分:0)
使用点按而不是点击此款式
private void Button_OnHold(object sender, GestureEventArgs e)
{
e.Handled = true;
// Your code goes here
}
private void Button_OnTap(object sender, GestureEventArgs e)
{
// Your code goes here
}
将Handled属性设置为true后,click事件将无法处理您的手势。