TouchView.Maui 1.0.1

dotnet add package TouchView.Maui --version 1.0.1
                    
NuGet\Install-Package TouchView.Maui -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TouchView.Maui" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TouchView.Maui" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="TouchView.Maui" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TouchView.Maui --version 1.0.1
                    
#r "nuget: TouchView.Maui, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TouchView.Maui@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TouchView.Maui&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=TouchView.Maui&version=1.0.1
                    
Install as a Cake Tool

TouchView.Maui

TouchView.Maui is a .NET MAUI library for receiving raw touch events on a MAUI layout.

Features

  • TouchView inherits from AbsoluteLayout.
  • Raw touch events: Down, Up, Panning, and Panned.
  • Touch coordinates through X, Y, and Position.
  • Android and iOS support.
  • ShouldConsumeTouchEvents controls whether the touch sequence can be consumed by TouchView.
  • 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: TouchView still observes the whole touch sequence where supported, but it does not intentionally block child controls from receiving input.
  • true: TouchView observes 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/CollectionView touch 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.props is 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, UseAsProjectReference defaults to false.
  • When UseAsProjectReference is false, the project uses its normal package-oriented target frameworks.
  • If you switch between package mode and project-reference mode, clean bin and obj folders 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 Compatible and additional computed target framework versions.
.NET net10.0-android36.0 is compatible.  net10.0-ios26.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 120 6/12/2026
1.0.0 110 5/27/2026