I found some strange behavior in this scenario.
Simple WPF project with a TextBox with two events PreviewTouchDown and PreviewMouseDown
<Window x:Class="WPF.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WPF"
mc:Ignorable="d"
Title="MainWindow"
Height="800"
Width="1000">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBox x:Name="TextBox"
PreviewTouchDown="TextBox_PreviewTouchDown"
PreviewMouseDown="TextBox_PreviewMouseDown" />
</Grid>
</Window>
in code behind open second window in the touch event.
private void TextBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
}
private void TextBox_PreviewTouchDown(object sender, TouchEventArgs e)
{
Window1 w = new Window1();
w.ShowDialog();
}
Open the second window by tap on the TextBox, then close the second window.
Do 9 touch tap in the blank area of the MainWindow (not on the TextBox),
at ninth the PreviewMouseDown is launched.
This thing doesn’t happen if i do e.Handle = true in the TextBox_PreviewTouchDown method.
I’m tryng with Windows 11, .Net Framework 4.8.1, VS2022.