Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/UniGetUI.Avalonia/Assets/Styles/Styles.Common.axaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:UniGetUI.Avalonia.Views.Controls"
xmlns:conv="using:UniGetUI.Avalonia.Converters"
xmlns:settings="using:UniGetUI.Avalonia.Views.Controls.Settings"
xmlns:primitives="using:Avalonia.Controls.Primitives"
xmlns:automation="clr-namespace:Avalonia.Automation;assembly=Avalonia.Controls">
Expand Down Expand Up @@ -671,7 +672,7 @@
</Style>

<Style Selector="DataGridCell">
<Setter Property="automation:AutomationProperties.Name" Value="{Binding $self.((Control)Content).(automation:AutomationProperties.Name)}"/>
<Setter Property="automation:AutomationProperties.Name" Value="{Binding $self.Content, Converter={x:Static conv:AutomationNameOfContentConverter.Instance}}"/>
</Style>

<Style Selector="RadioButton:checked /template/ Ellipse#CheckOuterEllipse">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Globalization;
using Avalonia.Automation;
using Avalonia.Controls;
using Avalonia.Data;
using Avalonia.Data.Converters;

namespace UniGetUI.Avalonia.Converters;

/// <summary>
/// Reads AutomationProperties.Name from a cell's content, tolerating the null content that
/// virtualized DataGrid cells have while they are recycled.
/// </summary>
public sealed class AutomationNameOfContentConverter : IValueConverter
{
public static readonly AutomationNameOfContentConverter Instance = new();

public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
=> value is Control control
? AutomationProperties.GetName(control)
: BindingOperations.DoNothing;

public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
=> throw new NotSupportedException();
}
Loading