TitleBar Buttons Have Hit Testing and Click Issues
Describe the bug
When using Wpf.Ui.Controls.TitleBar on a Windows touchscreen device, the window control buttons do not respond reliably to touch input.
- Tapping the maximize/restore button may cause the window to restore and then immediately maximize again, or the tap may appear to have no effect.
- Tapping the close button often does not close the window. It may require multiple taps before the click is successfully triggered.
Mouse input works correctly on the same buttons.
Example usage:
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
<ui:TitleBar x:Name="TitleBar">
<ui:TitleBar.Icon>
<ui:ImageIcon Margin="0,-5,-5,0" Source="{Binding Source={StaticResource ApplicationIcon}}" />
</ui:TitleBar.Icon>
<ui:TitleBar.Header>
<StackPanel VerticalAlignment="Center">
<TextBlock x:Name="TitleTextBlock" Text="Untitled window title" />
</StackPanel>
</ui:TitleBar.Header>
</ui:TitleBar>This issue is unrelated to the custom Header. Even with a minimal configuration such as:
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
<ui:TitleBar
Grid.Row="0"
Height="30"
ShowMaximize="False"
ShowMinimize="False" />the close button still exhibits the same issue.
To Reproduce
As shown in the attachment
Expected behavior
A single touch tap on the maximize/restore or close button should behave the same as a single mouse click.
The TitleBar caption buttons should respond reliably to touch input without requiring repeated taps or unexpectedly toggling the window state.
Consistent with native window behavior, or with WPF in new projects
Screenshots
Close Button
https://github.com/user-attachments/assets/435c9bcf-8127-44bf-aaa2-bf208ba64254
Maximize Button
https://github.com/user-attachments/assets/ef7dddf7-9c5f-4a59-b0ba-db0c55a1ec2d
OS version
Windows 10
.NET version
.NET 8 / WPF
WPF-UI NuGet version
4.3.0
Additional context
Under the same environment, title bar buttons in applications such as web browsers, File Explorer, and Windows Settings do not exhibit this issue.
Based on the relevant source code, I suspect this may be related to the custom native window message hook handling in TitleBar.
There is also another long-standing issue on the PC side: occasionally, when hovering the mouse over the close button, its hover state keeps flickering continuously, and the button may become unclickable. Mouse clicks on the button may stop working until the state recovers. This issue has existed for some time and has not been resolved.
Source: lepoco/wpfui