Invoke .NET MAUI Code

Wisej.NET Hybrid Local applications can use .NET MAUI directly from within the project.

Example Project

Setup

To get started, add <UseMaui>true</UseMaui> to a Wisej.NET Hybrid Local Application .csproj or .vbproj <PropertyGroup>.

Vibration Example

Triggering a vibration on a Wisej.NET button click.

private void button1_Click(object sender, System.EventArgs e)
{
#if ANDROID || IOS
	TimeSpan vibrationLength = TimeSpan.FromSeconds(3);
	Microsoft.Maui.Devices.Vibration.Default.Vibrate(vibrationLength);
#endif
}

Haptic Feedback Example

In Wisej.NET, all requests come in on a background thread. When invoking .NET MAUI code directly, you may need to run the call on the device's UI thread:

private void button1_Click(object sender, System.EventArgs e)
{
#if ANDROID || IOS
	Microsoft.Maui.ApplicationModel.MainThread.BeginInvokeOnMainThread(() =>
	{						 
                 Microsoft.Maui.Devices.HapticFeedback.Default.Perform(Microsoft.Maui.Devices.HapticFeedbackType.LongPress);
        });
#endif
}

Last updated