4 August 2022

Slider Example in MAUI

 In this example we are going to see Slider Example in MAUI. 

1) Add new page and Update code as below.

<?xml version="1.0" encoding="utf-8" ?>

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"

             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"

             x:Class="MauiApp1.SliderEXP1"

             Title="SliderEXP1">

    <VerticalStackLayout>

        <Slider x:Name="SliderName"

               Minimum="0" Maximum="10" MinimumTrackColor="Red" MaximumTrackColor="Green"

                ThumbColor="Yellow" ValueChanged="SliderName_ValueChanged"></Slider>

        <Label x:Name="lblSlider"></Label>

    </VerticalStackLayout>

</ContentPage>

2) Go to .CS page and update as below.

namespace MauiApp1;

public partial class SliderEXP1 : ContentPage

{

public SliderEXP1()

{

InitializeComponent();

}

private void SliderName_ValueChanged(object sender, ValueChangedEventArgs e)

{

lblSlider.Text = SliderName.Value.ToString();

    }

}

Output:

Code in Github: https://github.com/adi501/MAUI

No comments:

Post a Comment