Hello,
Welcome to our Microsoft Q&A platform!
You could use customrenderers to access UIAccessibilityTrait.Adjustable
. I test with a custom slider, it works. The two buttons display on Android and you also could add some logic code to change the slider value. You can have a try with the following code:
XAML
<StackLayout>
<Label
x:Name="labelShow"
Text= "ShowValue"
FontSize="Large"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand"></Label>
<Button Text="plus">
<Button.IsVisible>
<OnPlatform x:TypeArguments="x:Boolean"
iOS ="False"
Android ="True"/>
</Button.IsVisible>
</Button>
<Slider x:Name="slider"
Minimum="0"
Maximum="10"
ValueChanged="Slider_ValueChanged"
></Slider>
<Button Text="subtract">
<Button.IsVisible>
<OnPlatform x:TypeArguments="x:Boolean"
iOS ="False"
Android ="True"/>
</Button.IsVisible>
</Button>
</StackLayout>
void Slider_ValueChanged(System.Object sender, Xamarin.Forms.ValueChangedEventArgs e)
{
labelShow.Text = string.Format("value:{0}",e.NewValue);
}
customrenderers
using System;
using VoiceOverDemo.iOS;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly:ExportRenderer(typeof(Slider), typeof(MySlider))]
namespace VoiceOverDemo.iOS
{
public class MySlider:SliderRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Slider> e)
{
base.OnElementChanged(e);
if(Control != null) {
Control.BackgroundColor = UIKit.UIColor.Orange;
Control.AccessibilityTraits = UIKit.UIAccessibilityTrait.Adjustable;
}
}
}
}
screen shoot
Best Regards,
Wenyan Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.