I would like to change the style of my Avalonia Simple theme slider thumb. If I use the Fluent theme, and add
a Style, I can make it wider. Here’s how it looks in Fluent theme before adding the style:
Here’s how it looks in Fluent theme after adding the style:
Here’s the C# code to make it look like the second picture above:
using Avalonia;
using Avalonia.Controls;
using Avalonia.Styling;
using Avalonia.Controls.Primitives;
class MainClass
{
public static void Main(string[] args)
{
AppBuilder.Configure<Application>().UsePlatformDetect().Start(AppMain, args);
}
public static void AppMain(Application app, string[] args)
{
app.Styles.Add(new Avalonia.Themes.Fluent.FluentTheme());
var win = new Window { Width = 500, Height = 50, };
var slider = new Slider { Width = 480, };
slider.Styles.Add(
new Style(x => x.OfType<Slider>().Descendant().OfType<Thumb>())
{
Setters = { new Setter(Thumb.MinWidthProperty, 50.0), }
});
win.Content = slider;
win.Show();
app.Run(win);
}
}
But, if I change this line:
app.Styles.Add(new Avalonia.Themes.Fluent.FluentTheme());
to this line:
app.Styles.Add(new Avalonia.Themes.Simple.SimpleTheme());
which switches from Fluent theme to Simple theme, the slider looks like this:
The style that makes the thumb wider in Fluent theme has no effect on the thumb in Simple theme.
How can I make the thumb wider from C# when I am using Simple theme?