You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

33 lines
1.2 KiB

using Avalonia.Data.Converters;
using Avalonia.Media;
using System;
using System.Globalization;
namespace MyAvaloniaApp.Converters;
/// <summary>
/// 标签页样式转换器
/// </summary>
public class TabStyleConverter : IValueConverter
{
public static readonly TabStyleConverter Instance = new();
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is bool isSelected && parameter is string styleType)
{
return styleType switch
{
"Background" => isSelected ? new SolidColorBrush(Color.FromRgb(227, 242, 253)) : new SolidColorBrush(Colors.White),
"BorderBrush" => isSelected ? new SolidColorBrush(Color.FromRgb(33, 150, 243)) : new SolidColorBrush(Color.FromRgb(208, 208, 208)),
"Foreground" => isSelected ? new SolidColorBrush(Color.FromRgb(33, 150, 243)) : new SolidColorBrush(Colors.Black),
_ => new SolidColorBrush(Colors.White)
};
}
return new SolidColorBrush(Colors.White);
}
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}