Browse Source
Add basic support for automation for DataGrid and DataGridRow (#15174)
* Add basic support for automation for DataGrid and DataGridRow
* Add DataGridCellAutomationPeer
* Add DataGridColumnHeaderAutomationPeer
* Add DataGridColumnHeadersPresenterAutomationPeer
* Add DataGridDetailsPresenterAutomationPeer
pull/15177/head
Wiesław Šoltés
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with
160 additions and
0 deletions
-
src/Avalonia.Controls.DataGrid/Automation/Peers/DataGridAutomationPeer.cs
-
src/Avalonia.Controls.DataGrid/Automation/Peers/DataGridCellAutomationPeer.cs
-
src/Avalonia.Controls.DataGrid/Automation/Peers/DataGridColumnHeaderAutomationPeer.cs
-
src/Avalonia.Controls.DataGrid/Automation/Peers/DataGridColumnHeadersPresenterAutomationPeer.cs
-
src/Avalonia.Controls.DataGrid/Automation/Peers/DataGridDetailsPresenterAutomationPeer.cs
-
src/Avalonia.Controls.DataGrid/Automation/Peers/DataGridRowAutomationPeer.cs
-
src/Avalonia.Controls.DataGrid/DataGrid.cs
-
src/Avalonia.Controls.DataGrid/DataGridCell.cs
-
src/Avalonia.Controls.DataGrid/DataGridColumnHeader.cs
-
src/Avalonia.Controls.DataGrid/DataGridRow.cs
-
src/Avalonia.Controls.DataGrid/Primitives/DataGridColumnHeadersPresenter.cs
-
src/Avalonia.Controls.DataGrid/Primitives/DataGridDetailsPresenter.cs
|
|
@ -0,0 +1,18 @@ |
|
|
|
|
|
using Avalonia.Automation.Peers; |
|
|
|
|
|
|
|
|
|
|
|
namespace Avalonia.Controls.Automation.Peers; |
|
|
|
|
|
|
|
|
|
|
|
public class DataGridAutomationPeer : ControlAutomationPeer |
|
|
|
|
|
{ |
|
|
|
|
|
public DataGridAutomationPeer(DataGrid owner) |
|
|
|
|
|
: base(owner) |
|
|
|
|
|
{ |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public new DataGrid Owner => (DataGrid)base.Owner; |
|
|
|
|
|
|
|
|
|
|
|
protected override AutomationControlType GetAutomationControlTypeCore() |
|
|
|
|
|
{ |
|
|
|
|
|
return AutomationControlType.DataGrid; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
@ -0,0 +1,22 @@ |
|
|
|
|
|
using Avalonia.Automation.Peers; |
|
|
|
|
|
|
|
|
|
|
|
namespace Avalonia.Controls.Automation.Peers; |
|
|
|
|
|
|
|
|
|
|
|
public class DataGridCellAutomationPeer : ContentControlAutomationPeer |
|
|
|
|
|
{ |
|
|
|
|
|
public DataGridCellAutomationPeer(DataGridCell owner) |
|
|
|
|
|
: base(owner) |
|
|
|
|
|
{ |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public new DataGridCell Owner => (DataGridCell)base.Owner; |
|
|
|
|
|
|
|
|
|
|
|
protected override AutomationControlType GetAutomationControlTypeCore() |
|
|
|
|
|
{ |
|
|
|
|
|
return AutomationControlType.Custom; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected override bool IsContentElementCore() => true; |
|
|
|
|
|
|
|
|
|
|
|
protected override bool IsControlElementCore() => true; |
|
|
|
|
|
} |
|
|
@ -0,0 +1,22 @@ |
|
|
|
|
|
using Avalonia.Automation.Peers; |
|
|
|
|
|
|
|
|
|
|
|
namespace Avalonia.Controls.Automation.Peers; |
|
|
|
|
|
|
|
|
|
|
|
public class DataGridColumnHeaderAutomationPeer : ContentControlAutomationPeer |
|
|
|
|
|
{ |
|
|
|
|
|
public DataGridColumnHeaderAutomationPeer(DataGridColumnHeader owner) |
|
|
|
|
|
: base(owner) |
|
|
|
|
|
{ |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public new DataGridColumnHeader Owner => (DataGridColumnHeader)base.Owner; |
|
|
|
|
|
|
|
|
|
|
|
protected override AutomationControlType GetAutomationControlTypeCore() |
|
|
|
|
|
{ |
|
|
|
|
|
return AutomationControlType.HeaderItem; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected override bool IsContentElementCore() => false; |
|
|
|
|
|
|
|
|
|
|
|
protected override bool IsControlElementCore() => true; |
|
|
|
|
|
} |
|
|
@ -0,0 +1,23 @@ |
|
|
|
|
|
using Avalonia.Automation.Peers; |
|
|
|
|
|
using Avalonia.Controls.Primitives; |
|
|
|
|
|
|
|
|
|
|
|
namespace Avalonia.Controls.Automation.Peers; |
|
|
|
|
|
|
|
|
|
|
|
public class DataGridColumnHeadersPresenterAutomationPeer : ControlAutomationPeer |
|
|
|
|
|
{ |
|
|
|
|
|
public DataGridColumnHeadersPresenterAutomationPeer(DataGridColumnHeadersPresenter owner) |
|
|
|
|
|
: base(owner) |
|
|
|
|
|
{ |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public new DataGridColumnHeadersPresenter Owner => (DataGridColumnHeadersPresenter)base.Owner; |
|
|
|
|
|
|
|
|
|
|
|
protected override AutomationControlType GetAutomationControlTypeCore() |
|
|
|
|
|
{ |
|
|
|
|
|
return AutomationControlType.Header; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected override bool IsContentElementCore() => false; |
|
|
|
|
|
|
|
|
|
|
|
protected override bool IsControlElementCore() => true; |
|
|
|
|
|
} |
|
|
@ -0,0 +1,14 @@ |
|
|
|
|
|
using Avalonia.Automation.Peers; |
|
|
|
|
|
using Avalonia.Controls.Primitives; |
|
|
|
|
|
|
|
|
|
|
|
namespace Avalonia.Controls.Automation.Peers; |
|
|
|
|
|
|
|
|
|
|
|
public class DataGridDetailsPresenterAutomationPeer : ControlAutomationPeer |
|
|
|
|
|
{ |
|
|
|
|
|
public DataGridDetailsPresenterAutomationPeer(DataGridDetailsPresenter owner) |
|
|
|
|
|
: base(owner) |
|
|
|
|
|
{ |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public new DataGridDetailsPresenter Owner => (DataGridDetailsPresenter)base.Owner; |
|
|
|
|
|
} |
|
|
@ -0,0 +1,20 @@ |
|
|
|
|
|
using Avalonia.Controls; |
|
|
|
|
|
|
|
|
|
|
|
namespace Avalonia.Automation.Peers |
|
|
|
|
|
{ |
|
|
|
|
|
public class DataGridRowAutomationPeer : ControlAutomationPeer |
|
|
|
|
|
{ |
|
|
|
|
|
public DataGridRowAutomationPeer(DataGridRow owner) |
|
|
|
|
|
: base(owner) |
|
|
|
|
|
{ |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected override AutomationControlType GetAutomationControlTypeCore() |
|
|
|
|
|
{ |
|
|
|
|
|
return AutomationControlType.DataItem; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected override bool IsContentElementCore() => true; |
|
|
|
|
|
protected override bool IsControlElementCore() => true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
@ -22,6 +22,8 @@ using System.Text; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
using Avalonia.Input.Platform; |
|
|
using Avalonia.Input.Platform; |
|
|
using System.ComponentModel.DataAnnotations; |
|
|
using System.ComponentModel.DataAnnotations; |
|
|
|
|
|
using Avalonia.Automation.Peers; |
|
|
|
|
|
using Avalonia.Controls.Automation.Peers; |
|
|
using Avalonia.Controls.Utils; |
|
|
using Avalonia.Controls.Utils; |
|
|
using Avalonia.Layout; |
|
|
using Avalonia.Layout; |
|
|
using Avalonia.Controls.Metadata; |
|
|
using Avalonia.Controls.Metadata; |
|
|
@ -800,6 +802,11 @@ namespace Avalonia.Controls |
|
|
UpdatePseudoClasses(); |
|
|
UpdatePseudoClasses(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected override AutomationPeer OnCreateAutomationPeer() |
|
|
|
|
|
{ |
|
|
|
|
|
return new DataGridAutomationPeer(this); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private void SetValueNoCallback<T>(AvaloniaProperty<T> property, T value, BindingPriority priority = BindingPriority.LocalValue) |
|
|
private void SetValueNoCallback<T>(AvaloniaProperty<T> property, T value, BindingPriority priority = BindingPriority.LocalValue) |
|
|
{ |
|
|
{ |
|
|
_areHandlersSuspended = true; |
|
|
_areHandlersSuspended = true; |
|
|
|
|
|
@ -3,6 +3,8 @@ |
|
|
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
|
|
|
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
|
|
|
// All other rights reserved.
|
|
|
// All other rights reserved.
|
|
|
|
|
|
|
|
|
|
|
|
using Avalonia.Automation.Peers; |
|
|
|
|
|
using Avalonia.Controls.Automation.Peers; |
|
|
using Avalonia.Controls.Metadata; |
|
|
using Avalonia.Controls.Metadata; |
|
|
using Avalonia.Controls.Primitives; |
|
|
using Avalonia.Controls.Primitives; |
|
|
using Avalonia.Controls.Shapes; |
|
|
using Avalonia.Controls.Shapes; |
|
|
@ -123,6 +125,11 @@ namespace Avalonia.Controls |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected override AutomationPeer OnCreateAutomationPeer() |
|
|
|
|
|
{ |
|
|
|
|
|
return new DataGridCellAutomationPeer(this); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Builds the visual tree for the cell control when a new template is applied.
|
|
|
/// Builds the visual tree for the cell control when a new template is applied.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
|
|
|
@ -6,7 +6,9 @@ |
|
|
using System; |
|
|
using System; |
|
|
using System.ComponentModel; |
|
|
using System.ComponentModel; |
|
|
using System.Diagnostics; |
|
|
using System.Diagnostics; |
|
|
|
|
|
using Avalonia.Automation.Peers; |
|
|
using Avalonia.Collections; |
|
|
using Avalonia.Collections; |
|
|
|
|
|
using Avalonia.Controls.Automation.Peers; |
|
|
using Avalonia.Controls.Metadata; |
|
|
using Avalonia.Controls.Metadata; |
|
|
using Avalonia.Controls.Mixins; |
|
|
using Avalonia.Controls.Mixins; |
|
|
using Avalonia.Controls.Utils; |
|
|
using Avalonia.Controls.Utils; |
|
|
@ -87,6 +89,11 @@ namespace Avalonia.Controls |
|
|
PointerExited += DataGridColumnHeader_PointerExited; |
|
|
PointerExited += DataGridColumnHeader_PointerExited; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected override AutomationPeer OnCreateAutomationPeer() |
|
|
|
|
|
{ |
|
|
|
|
|
return new DataGridColumnHeaderAutomationPeer(this); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private void OnAreSeparatorsVisibleChanged(AvaloniaPropertyChangedEventArgs e) |
|
|
private void OnAreSeparatorsVisibleChanged(AvaloniaPropertyChangedEventArgs e) |
|
|
{ |
|
|
{ |
|
|
if (!_areHandlersSuspended) |
|
|
if (!_areHandlersSuspended) |
|
|
|
|
|
@ -15,6 +15,7 @@ using Avalonia.Utilities; |
|
|
using Avalonia.VisualTree; |
|
|
using Avalonia.VisualTree; |
|
|
using System; |
|
|
using System; |
|
|
using System.Diagnostics; |
|
|
using System.Diagnostics; |
|
|
|
|
|
using Avalonia.Automation.Peers; |
|
|
using Avalonia.Reactive; |
|
|
using Avalonia.Reactive; |
|
|
|
|
|
|
|
|
namespace Avalonia.Controls |
|
|
namespace Avalonia.Controls |
|
|
@ -150,6 +151,11 @@ namespace Avalonia.Controls |
|
|
Cells.CellRemoved += DataGridCellCollection_CellRemoved; |
|
|
Cells.CellRemoved += DataGridCellCollection_CellRemoved; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected override AutomationPeer OnCreateAutomationPeer() |
|
|
|
|
|
{ |
|
|
|
|
|
return new DataGridRowAutomationPeer(this); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private void SetValueNoCallback<T>(AvaloniaProperty<T> property, T value, BindingPriority priority = BindingPriority.LocalValue) |
|
|
private void SetValueNoCallback<T>(AvaloniaProperty<T> property, T value, BindingPriority priority = BindingPriority.LocalValue) |
|
|
{ |
|
|
{ |
|
|
_areHandlersSuspended = true; |
|
|
_areHandlersSuspended = true; |
|
|
|
|
|
@ -8,6 +8,8 @@ using Avalonia.Media; |
|
|
using System; |
|
|
using System; |
|
|
using System.Collections.Specialized; |
|
|
using System.Collections.Specialized; |
|
|
using System.Diagnostics; |
|
|
using System.Diagnostics; |
|
|
|
|
|
using Avalonia.Automation.Peers; |
|
|
|
|
|
using Avalonia.Controls.Automation.Peers; |
|
|
|
|
|
|
|
|
namespace Avalonia.Controls.Primitives |
|
|
namespace Avalonia.Controls.Primitives |
|
|
{ |
|
|
{ |
|
|
@ -126,6 +128,11 @@ namespace Avalonia.Controls.Primitives |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected override AutomationPeer OnCreateAutomationPeer() |
|
|
|
|
|
{ |
|
|
|
|
|
return new DataGridColumnHeadersPresenterAutomationPeer(this); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Arranges the content of the <see cref="T:Avalonia.Controls.Primitives.DataGridColumnHeadersPresenter" />.
|
|
|
/// Arranges the content of the <see cref="T:Avalonia.Controls.Primitives.DataGridColumnHeadersPresenter" />.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
|
|
|
@ -6,6 +6,8 @@ |
|
|
using System; |
|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.Text; |
|
|
using System.Text; |
|
|
|
|
|
using Avalonia.Automation.Peers; |
|
|
|
|
|
using Avalonia.Controls.Automation.Peers; |
|
|
using Avalonia.Media; |
|
|
using Avalonia.Media; |
|
|
|
|
|
|
|
|
namespace Avalonia.Controls.Primitives |
|
|
namespace Avalonia.Controls.Primitives |
|
|
@ -43,6 +45,11 @@ namespace Avalonia.Controls.Primitives |
|
|
AffectsMeasure<DataGridDetailsPresenter>(ContentHeightProperty); |
|
|
AffectsMeasure<DataGridDetailsPresenter>(ContentHeightProperty); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected override AutomationPeer OnCreateAutomationPeer() |
|
|
|
|
|
{ |
|
|
|
|
|
return new DataGridDetailsPresenterAutomationPeer(this); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Arranges the content of the <see cref="T:Avalonia.Controls.Primitives.DataGridDetailsPresenter" />.
|
|
|
/// Arranges the content of the <see cref="T:Avalonia.Controls.Primitives.DataGridDetailsPresenter" />.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
|