TouchView.Maui
1.0.1
dotnet add package TouchView.Maui --version 1.0.1
NuGet\Install-Package TouchView.Maui -Version 1.0.1
<PackageReference Include="TouchView.Maui" Version="1.0.1" />
<PackageVersion Include="TouchView.Maui" Version="1.0.1" />
<PackageReference Include="TouchView.Maui" />
paket add TouchView.Maui --version 1.0.1
#r "nuget: TouchView.Maui, 1.0.1"
#:package TouchView.Maui@1.0.1
#addin nuget:?package=TouchView.Maui&version=1.0.1
#tool nuget:?package=TouchView.Maui&version=1.0.1
TouchView.Maui
TouchView.Maui is a .NET MAUI library for receiving raw touch events on a MAUI layout.
Features
TouchViewinherits fromAbsoluteLayout.- Raw touch events:
Down,Up,Panning, andPanned. - Touch coordinates through
X,Y, andPosition. - Android and iOS support.
ShouldConsumeTouchEventscontrols whether the touch sequence can be consumed byTouchView.- Registration through
builder.UseTouchViewMaui(). - Sample app included.
Installation
Install the package from NuGet:
dotnet add package TouchView.Maui --version 1.0.1
Setup
Register the handler in MauiProgram.cs:
using TouchView.Maui;
builder
.UseMauiApp<App>()
.UseTouchViewMaui();
XAML Example
<ContentPage
x:Class="YourApp.MainPage"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:touch="clr-namespace:TouchView.Maui;assembly=TouchView.Maui">
<touch:TouchView
Down="OnTouchDown"
Panning="OnTouchPanning"
Up="OnTouchUp"
Panned="OnTouchPanned"
ShouldConsumeTouchEvents="False">
</touch:TouchView>
</ContentPage>
Code-Behind Example
private void OnTouchDown(object? sender, TouchViewEventArgs e)
{
var x = e.X;
var y = e.Y;
var position = e.Position;
Console.WriteLine($"Down at X: {x}, Y: {y}, Position: {position}");
}
Events
Down: first contact.Panning: touch movement.Up: release or cancellation.Panned: end of the pan, raised only if movement happened.
ShouldConsumeTouchEvents
ShouldConsumeTouchEvents controls how TouchView participates in the touch sequence:
false:TouchViewstill observes the whole touch sequence where supported, but it does not intentionally block child controls from receiving input.true:TouchViewobserves events and can consume/block the gesture.
On empty Android areas, the library keeps the touch sequence alive so it can continue receiving Move and Up events.
Sample App
The sample app is in SAMPLE/TouchView.Maui.Sample.
It shows:
- Live coordinates.
- Last received event.
- Event log.
- Consume switch.
- Child button inside
TouchView.
Build
dotnet restore TouchView.Maui.sln
dotnet build TouchView.Maui/TouchView.Maui.csproj -f net10.0-android
dotnet build TouchView.Maui/TouchView.Maui.csproj -f net10.0-ios
Test
For a MAUI multi-target solution, avoid running:
dotnet test
It can build Android, iOS, and the MAUI sample app too.
There is no TouchView.Maui.Tests/TouchView.Maui.Tests.csproj project in the current solution. If a focused test project is added, prefer running it directly:
dotnet test TouchView.Maui.Tests/TouchView.Maui.Tests.csproj -f net10.0
To build Android separately:
dotnet build TouchView.Maui/TouchView.Maui.csproj -f net10.0-android
Troubleshooting
XARDF7024: Directory not empty
If Android build fails under obj/Debug/net10.0-android/lp, it is often caused by dirty obj/bin folders or parallel Android builds.
Try cleaning generated folders and restoring again:
rm -rf TouchView.Maui/bin TouchView.Maui/obj
rm -rf SAMPLE/TouchView.Maui.Sample/bin SAMPLE/TouchView.Maui.Sample/obj
dotnet restore
XA0033: Java version
This is an Android tooling/environment warning. It is not necessarily an error in the library.
Requirements
- .NET 10.
- .NET MAUI workload.
- Android or iOS workload for the target you want to build.
Known Limitations
- Advanced multi-touch is not supported yet.
- Windows is not included in v1.
- A
TouchListView/CollectionViewtouch wrapper is not included in v1.
Local development with ProjectReference
This library is intended to be consumed primarily as a NuGet package.
For local development, debugging, or testing changes before publishing a new package, you can also clone the repository and reference the project directly with a ProjectReference from a consuming .NET MAUI app.
This mode is optional and should be treated as a development-only workflow. Normal consumers should use the NuGet package.
Enable ProjectReference mode locally
To enable local ProjectReference mode, create a file named:
Directory.Build.local.props
in the same directory as:
Directory.Build.props
Do not commit this file. It is meant to contain local machine/developer settings only.
Recommended local configuration:
<Project>
<PropertyGroup>
<UseAsProjectReference>true</UseAsProjectReference>
<OverrideAndroidSpecificVersion>36.0</OverrideAndroidSpecificVersion>
</PropertyGroup>
</Project>
What this does
By default, the project uses package-oriented, generic .NET MAUI platform TFMs, for example:
net10.0-ios
net10.0-android
When UseAsProjectReference is enabled, the project can adjust its target frameworks to match the platform-specific target required by a consuming app.
For example, with:
<OverrideAndroidSpecificVersion>36.0</OverrideAndroidSpecificVersion>
the Android target becomes:
net10.0-android36.0
This is useful when a consuming app targets a specific Android platform version and the library is referenced directly as a project instead of as a NuGet package.
If UseAsProjectReference=true is set and OverrideAndroidSpecificVersion is not provided, the project is configured to fall back to Android 36.0 for ProjectReference mode. Setting the value explicitly is still recommended because it makes the consuming setup easier to read.
Optional iOS override
If a consuming app requires a specific iOS platform version, use:
<OverrideIosSpecificVersion>26.0</OverrideIosSpecificVersion>
In that case, the iOS target becomes:
net10.0-ios26.0
If OverrideIosSpecificVersion is not set, the iOS target remains generic:
net10.0-ios
Important notes
Directory.Build.local.propsis for local development only.- Do not commit
Directory.Build.local.props. - Normal NuGet builds and CI builds should run without this local file.
- When the local file is not present,
UseAsProjectReferencedefaults tofalse. - When
UseAsProjectReferenceisfalse, the project uses its normal package-oriented target frameworks. - If you switch between package mode and project-reference mode, clean
binandobjfolders before rebuilding. - Restore and build should be performed in the same mode. If restore runs with local overrides enabled, build should use the same overrides.
- If Rider keeps building against an old Android/iOS target after switching modes, reload all projects. If the problem persists, use File > Invalidate Caches... and reopen the solution.
Packing and testing the NuGet package locally
When creating or testing the NuGet package, make sure the local ProjectReference overrides are disabled. Otherwise the package can be produced with development-specific target frameworks.
Before packing, temporarily rename the local props file if it exists:
mv Directory.Build.local.props Directory.Build.local.props.disabled
Then clean generated folders from the repository root:
find . -type d \( -name bin -o -name obj \) -prune -exec rm -rf {} +
Pack the library by calling dotnet pack directly on the library .csproj, not on the solution root:
dotnet pack TouchView.Maui/TouchView.Maui.csproj \
-c Release \
-o ./local-nuget
Packing the concrete library project avoids unintentionally building sample apps, tests, or other projects in the solution.
After packing, you can re-enable your local development settings:
mv Directory.Build.local.props.disabled Directory.Build.local.props
To inspect the generated package contents:
unzip -l ./local-nuget/TouchView.Maui.1.0.1.nupkg | grep "lib/"
With .NET MAUI/.NET 10, it is normal for the generated .nupkg to contain platform-normalized asset folders such as:
lib/net10.0-android36.0/
lib/net10.0-ios26.0/
even when the project file declares generic TFMs such as net10.0-android or net10.0-ios. Those platform versions are resolved by the installed .NET SDK/workloads during build/pack.
To test the package without publishing it, add ./local-nuget as a local NuGet source in a consuming app and use the normal PackageReference workflow. This is the best way to verify the package as a real consumer would use it.
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-android36.0 is compatible. net10.0-ios26.0 is compatible. |
-
net10.0-android36.0
- Microsoft.Maui.Controls (>= 10.0.20)
-
net10.0-ios26.0
- Microsoft.Maui.Controls (>= 10.0.20)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.