diff options
5 files changed, 61 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> diff --git a/Xamarin.PropertyEditing/Properties/Resources.Designer.cs b/Xamarin.PropertyEditing/Properties/Resources.Designer.cs index 7ab73b3..c8cc438 100644 --- a/Xamarin.PropertyEditing/Properties/Resources.Designer.cs +++ b/Xamarin.PropertyEditing/Properties/Resources.Designer.cs @@ -1264,5 +1264,11 @@ namespace Xamarin.PropertyEditing.Properties { return ResourceManager.GetString("UncommonPropertiesName", resourceCulture); } } + + public static string PropertyButtonName { + get { + return ResourceManager.GetString("PropertyButtonName", resourceCulture); + } + } } } diff --git a/Xamarin.PropertyEditing/Properties/Resources.resx b/Xamarin.PropertyEditing/Properties/Resources.resx index 8e29b7a..e778724 100644 --- a/Xamarin.PropertyEditing/Properties/Resources.resx +++ b/Xamarin.PropertyEditing/Properties/Resources.resx @@ -806,4 +806,7 @@ <data name="ArrangeByButtonName" xml:space="preserve"> <value>Arrange by {0}</value> </data> + <data name="PropertyButtonName" xml:space="preserve"> + <value>Advanced options</value> + </data> </root>
\ No newline at end of file |