Refactor PropertyGrid UI, converters, and solution setup
- Improved PropertyGrid.axaml formatting and control styles; ensured spinner buttons are always visible and ColorPicker layouts are flexible; disabled horizontal scrolling in property list. - Reformatted property editors and group/category display for clarity. - Made all value converters sealed, added XML docs, and updated ConvertBack to throw NotImplementedException where unsupported. - Enhanced search logic to use StringComparison.OrdinalIgnoreCase. - Minor code style fixes (e.g., char literals for string checks). - Removed default value assignment for _useProxy in AdvancedConfiguration.cs. - Updated Program.cs in examples to use sealed Program classes. - Added PropertyGrid.slnx to organize solution and projects.
This commit is contained in:
@@ -8,8 +8,16 @@ namespace Avalonia.PropertyGrid.Controls;
|
||||
/// <summary>
|
||||
/// Converts an Avalonia.Media.Color to a SolidColorBrush
|
||||
/// </summary>
|
||||
public class ColorToBrushConverter : IValueConverter
|
||||
public sealed class ColorToBrushConverter : IValueConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts a Color to a SolidColorBrush.
|
||||
/// </summary>
|
||||
/// <param name="value">The Color value to convert.</param>
|
||||
/// <param name="targetType">The target type.</param>
|
||||
/// <param name="parameter">Optional parameter.</param>
|
||||
/// <param name="culture">Culture information.</param>
|
||||
/// <returns>A SolidColorBrush with the specified color.</returns>
|
||||
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is Color color)
|
||||
@@ -21,9 +29,17 @@ public class ColorToBrushConverter : IValueConverter
|
||||
return new SolidColorBrush(Colors.Transparent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a SolidColorBrush back to a Color.
|
||||
/// </summary>
|
||||
/// <param name="value">The SolidColorBrush value to convert back.</param>
|
||||
/// <param name="targetType">The target type.</param>
|
||||
/// <param name="parameter">Optional parameter.</param>
|
||||
/// <param name="culture">Culture information.</param>
|
||||
/// <returns>The Color from the brush.</returns>
|
||||
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is SolidColorBrush brush && brush.Color != null)
|
||||
if (value is SolidColorBrush brush)
|
||||
{
|
||||
return brush.Color;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user