The49.Maui.MaterialSwitch 1.0.0-alpha1

This is a prerelease version of The49.Maui.MaterialSwitch.
dotnet add package The49.Maui.MaterialSwitch --version 1.0.0-alpha1                
NuGet\Install-Package The49.Maui.MaterialSwitch -Version 1.0.0-alpha1                
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="The49.Maui.MaterialSwitch" Version="1.0.0-alpha1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add The49.Maui.MaterialSwitch --version 1.0.0-alpha1                
#r "nuget: The49.Maui.MaterialSwitch, 1.0.0-alpha1"                
#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.
// Install The49.Maui.MaterialSwitch as a Cake Addin
#addin nuget:?package=The49.Maui.MaterialSwitch&version=1.0.0-alpha1&prerelease

// Install The49.Maui.MaterialSwitch as a Cake Tool
#tool nuget:?package=The49.Maui.MaterialSwitch&version=1.0.0-alpha1&prerelease                

What is Maui.MaterialSwitch?

The .NET MAUI MaterialSwitch plugin adds the ability to use android Material 3 switches instead of the SwitchCompat used as default.

Getting Started

In order to use the plugin you need to call the extension method in your MauiProgram.cs file as follows:

using Plugin.ContextMenu;

public static class MauiProgram
{
	public static MauiApp CreateMauiApp()
	{
		var builder = MauiApp.CreateBuilder();
		
		// Initialise the plugin
		builder.UseMauiApp<App>()
			.UseMaterialSwitch();

		// the rest of your logic...
	}
}

You also need to make sure your application's theme extends the Material3 theme. This mean you need a Platforms/Android/Resources/values/styles.xml file with the following content:

<?xml version="1.0" encoding="utf-8" ?>
<resources>
	<style name="Maui.MainTheme" parent="Theme.Material3.DayNight"></style>
</resources>

If you aleready have this file, just make sure the Maui.MainTheme style inherits the Theme.Material3.DayNight parent.

Selectively use the MaterialSwitch

You can decide to not change the default Switch control. Call UseMaterialSwitch with applyToAll set to false.

	.UseMaterialSwitch(applyToAll: false)

You can then use the MaterialSwitch control selectively. Simply add the following namespace:

xmlns:the49="https://schemas.the49.com/dotnet/2023/maui"

Then use <the49:MaterialSwitch /> alongside <Switch />.

Notes

This will NOT change the switches on any other platform than Android


Made within The49

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-android33.0 is compatible.  net7.0-ios was computed.  net7.0-ios16.1 is compatible.  net7.0-maccatalyst was computed.  net7.0-maccatalyst16.1 is compatible.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net7.0-windows10.0.19041 is compatible.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net7.0

    • No dependencies.
  • net7.0-android33.0

    • No dependencies.
  • net7.0-ios16.1

    • No dependencies.
  • net7.0-maccatalyst16.1

    • No dependencies.
  • net7.0-windows10.0.19041

    • No dependencies.

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.0-alpha1 3,398 1/11/2023