📝 | This is a MAUI version of my Xamarin NuGet |
---|
This is a switch/ toggle control that would allow you to create any style switch you'd like.
This component is built on top/ from this great libary - https://github.com/Phenek/Global.InputForms. Fixes a few issues, adds more options for styling and improved accessibility.
Take a look at the demo app included within this project -
Install the NuGet package into your shared project project
Install-Package IeuanWalker.Maui.Switch
Then in the MauiProgram.cs
file, and the using statement -
using IeuanWalker.Maui.Switch;
And call .UseSwitch()
on MauiAppBuilder
-
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseSwitch()
This control contains 2 seperate controls, CustomSwitch
and SwitchView
.
Essentially CustomSwitch
allows you to design the induvidual parts of the switch, and the control handles all the logic for animating and changing the switch between the true/ false states
SwitchView
gives you a blank canves to design any type of switch you want. It gives you the standard properties of a switch and makes it completely accessible.
Check the wiki guide for how to use them, and to view the examples -
Both iOS and android see's this control as a native switch. So from an accessibility POV it behaves like a native switch.
To make the switch even more accessible set the SemanticProperties.Hint
property on the control, to let the user know what the switch is for.