重複の可能性:
WPF:ボタンのシングルクリック+ダブルクリックの問題
WPF / MVVM-ViewModelのTreeViewItemsのダブルクリックを処理する方法は?
WPFアプリケーションのボタンのシングルクリックとダブルクリックの両方を異なる反応で処理する必要があります。ワンクリックでボタンにフォーカスがあることだけを表示し、ダブルクリックで新しいウィンドウを表示したい(Windowsアイコンの動作と同様)。ただし、ダブルクリックすると、WPFは2回のクリックを実行するため、この状況を処理するのは困難です。誰かがこの問題を解決するのを手伝ってもらえますか?助けてくれてありがとう。
私はこれを試しました:
private static DispatcherTimer myClickWaitTimer =
new DispatcherTimer(
new TimeSpan(0, 0, 0, 1),
DispatcherPriority.Background,
mouseWaitTimer_Tick,
Dispatcher.CurrentDispatcher);
private void Button_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
// Stop the timer from ticking.
myClickWaitTimer.Stop();
Trace.WriteLine("Double Click");
e.Handled = true;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
myClickWaitTimer.Start();
}
private static void mouseWaitTimer_Tick(object sender, EventArgs e)
{
myClickWaitTimer.Stop();
// Handle Single Click Actions
MainWindow c = new MainWindow()
c.focusButton.Background = new SolidColorBrush(Colors.DarkBlue);
}
しかし、focusButtonをクリックしても、focusButtonBacgroundは変更されませんでした。