Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Maupin <ermaup@microsoft.com>2019-09-09 23:44:29 +0300
committerEric Maupin <ermaup@microsoft.com>2019-09-09 23:47:09 +0300
commit9de1b2965f0b52771928896ef1d5237a07b443ce (patch)
tree15d39584b0041706ecb76fd72a924ab4ed135c50 /Xamarin.PropertyEditing.Windows
parentb100cf55a56de7ae45a37fdc5a2b82a0edf9b504 (diff)
[Win] Include property button in A11y tree
Diffstat (limited to 'Xamarin.PropertyEditing.Windows')
-rw-r--r--Xamarin.PropertyEditing.Windows/PropertyButton.cs50
-rw-r--r--Xamarin.PropertyEditing.Windows/Themes/Resources.xaml2
-rw-r--r--Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj1
3 files changed, 52 insertions, 1 deletions
diff --git a/Xamarin.PropertyEditing.Windows/PropertyButton.cs b/Xamarin.PropertyEditing.Windows/PropertyButton.cs
index ba3c4ee..b5c210a 100644
--- a/Xamarin.PropertyEditing.Windows/PropertyButton.cs
+++ b/Xamarin.PropertyEditing.Windows/PropertyButton.cs
@@ -3,6 +3,8 @@ using System.Linq;
using System.Collections;
using System.ComponentModel;
using System.Windows;
+using System.Windows.Automation.Peers;
+using System.Windows.Automation.Provider;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
@@ -90,6 +92,11 @@ namespace Xamarin.PropertyEditing.Windows
this.menu.IsOpen = true;
}
+ protected override AutomationPeer OnCreateAutomationPeer ()
+ {
+ return new PropertyButtonAutomationPeer (this);
+ }
+
private Rectangle indicator;
private ContextMenu menu;
private PropertyViewModel vm;
@@ -199,5 +206,48 @@ namespace Xamarin.PropertyEditing.Windows
popup.SetResourceReference (Popup.StyleProperty, "CustomExpressionPopup");
popup.IsOpen = true;
}
+
+ private class PropertyButtonAutomationPeer
+ : FrameworkElementAutomationPeer, IInvokeProvider
+ {
+ public PropertyButtonAutomationPeer (PropertyButton button)
+ : base (button)
+ {
+ Button = button;
+ }
+
+ protected PropertyButton Button
+ {
+ get;
+ }
+
+ public void Invoke ()
+ {
+ Button.ShowMenu ();
+ }
+
+ public override object GetPattern (PatternInterface patternInterface)
+ {
+ if (patternInterface == PatternInterface.Invoke)
+ return this;
+
+ return base.GetPattern (patternInterface);
+ }
+
+ protected override bool IsControlElementCore ()
+ {
+ return Button.IsVisible;
+ }
+
+ protected override string GetClassNameCore ()
+ {
+ return nameof(PropertyButton);
+ }
+
+ protected override AutomationControlType GetAutomationControlTypeCore ()
+ {
+ return AutomationControlType.Button;
+ }
+ }
}
} \ No newline at end of file
diff --git a/Xamarin.PropertyEditing.Windows/Themes/Resources.xaml b/Xamarin.PropertyEditing.Windows/Themes/Resources.xaml
index b9a24be..4a883d6 100644
--- a/Xamarin.PropertyEditing.Windows/Themes/Resources.xaml
+++ b/Xamarin.PropertyEditing.Windows/Themes/Resources.xaml
@@ -1630,7 +1630,7 @@
<local:ToggleButtonEx x:Name="delveButton" Grid.Row="1" Grid.Column="0" Style="{DynamicResource StandaloneToggleStyle}" Width="11" Height="11" Visibility="{Binding HasItems,ElementName=subProperties,Converter={StaticResource BoolToVisibilityConverter}}" HorizontalContentAlignment="Left" />
<TextBlock Name="Label" Margin="0,3,0,3" Grid.Row="1" Grid.Column="1" Text="{TemplateBinding Label}" ToolTip="{Binding Property.Description,Mode=OneTime}" VerticalAlignment="Center" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" />
<ContentPresenter Grid.Row="1" Grid.RowSpan="2" Grid.Column="2" Margin="4,2,0,2" IsEnabled="{Binding Property.CanWrite}" MinHeight="20" />
- <local:PropertyButton x:Name="propertyButton" Grid.Row="1" Grid.RowSpan="2" Grid.Column="3" ValueSource="{Binding ValueSource}" IsEnabled="{Binding Property.CanWrite,Mode=OneTime}"/>
+ <local:PropertyButton x:Name="propertyButton" Grid.Row="1" Grid.RowSpan="2" Grid.Column="3" ValueSource="{Binding ValueSource}" IsEnabled="{Binding Property.CanWrite,Mode=OneTime}" AutomationProperties.Name="{x:Static prop:Resources.PropertyButtonName}" />
<ItemsControl Name="subProperties" Background="{DynamicResource PanelGroupSecondaryBackgroundBrush}" Margin="{TemplateBinding Padding,Converter={StaticResource NegativeThicknessConverter}}" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="4" ItemsSource="{TemplateBinding ItemsSource}" ItemTemplate="{DynamicResource PropertyEditorTemplate}">
<ItemsControl.Visibility>
diff --git a/Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj b/Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj
index 3aebf5b..b21e249 100644
--- a/Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj
+++ b/Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj
@@ -45,6 +45,7 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
+ <Reference Include="UIAutomationProvider" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>