diff options
author | Eric Maupin <ermaup@microsoft.com> | 2019-09-09 23:03:47 +0300 |
---|---|---|
committer | Eric Maupin <ermaup@microsoft.com> | 2019-09-09 23:03:47 +0300 |
commit | b100cf55a56de7ae45a37fdc5a2b82a0edf9b504 (patch) | |
tree | 22c15af47708a9504b0ef3993aa6ce63dc971736 /Xamarin.PropertyEditing.Windows | |
parent | ab42eb3a08ad8cb9ce8948b02c5553e951227821 (diff) |
[Win] A11y hide variant buttons
Diffstat (limited to 'Xamarin.PropertyEditing.Windows')
3 files changed, 36 insertions, 6 deletions
diff --git a/Xamarin.PropertyEditing.Windows/ButtonEx.cs b/Xamarin.PropertyEditing.Windows/ButtonEx.cs new file mode 100644 index 0000000..474043f --- /dev/null +++ b/Xamarin.PropertyEditing.Windows/ButtonEx.cs @@ -0,0 +1,29 @@ +using System.Windows; +using System.Windows.Automation.Peers; +using System.Windows.Controls; + +namespace Xamarin.PropertyEditing.Windows +{ + internal class ButtonEx + : Button + { + protected override AutomationPeer OnCreateAutomationPeer () + { + return new ButtonExAutomationPeer (this); + } + + private class ButtonExAutomationPeer + : ButtonAutomationPeer + { + public ButtonExAutomationPeer (Button owner) + : base (owner) + { + } + + protected override bool IsControlElementCore () + { + return base.IsControlElementCore () && Owner.IsVisible; + } + } + } +} diff --git a/Xamarin.PropertyEditing.Windows/Themes/Resources.xaml b/Xamarin.PropertyEditing.Windows/Themes/Resources.xaml index 7027ac6..b9a24be 100644 --- a/Xamarin.PropertyEditing.Windows/Themes/Resources.xaml +++ b/Xamarin.PropertyEditing.Windows/Themes/Resources.xaml @@ -1571,20 +1571,20 @@ <RowDefinition Height="Auto" /> </Grid.RowDefinitions> - <Button Name="addVariant" Grid.Column="0" Grid.Row="1" Margin="{TemplateBinding Padding,Converter={StaticResource NegativeThicknessConverter}}" Style="{StaticResource VariantButton}" Command="{Binding RequestCreateVariantCommand,Mode=OneTime}" ToolTip="{x:Static prop:Resources.AddVariant}" AutomationProperties.Name="{x:Static prop:Resources.AddVariant}"> - <Button.Visibility> + <local:ButtonEx Name="addVariant" Grid.Column="0" Grid.Row="1" Margin="{TemplateBinding Padding,Converter={StaticResource NegativeThicknessConverter}}" Style="{StaticResource VariantButton}" Command="{Binding RequestCreateVariantCommand,Mode=OneTime}" ToolTip="{x:Static prop:Resources.AddVariant}" AutomationProperties.Name="{x:Static prop:Resources.AddVariant}"> + <local:ButtonEx.Visibility> <MultiBinding Converter="{StaticResource BoolsToVisibilityConverter}"> <Binding Path="HasVariations" Mode="OneTime" /> <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ShowVariants" /> <Binding Path="IsEnabled" RelativeSource="{RelativeSource Self}" /> </MultiBinding> - </Button.Visibility> + </local:ButtonEx.Visibility> <Grid Width="6" Height="6" VerticalAlignment="Center" HorizontalAlignment="Center"> <Line X1="0" X2="6" Y1="3" Y2="3" Stroke="{Binding RelativeSource={RelativeSource AncestorType=Button},Path=Foreground}" StrokeThickness="1" /> <Line X1="3" X2="3" Y1="0" Y2="6" Stroke="{Binding RelativeSource={RelativeSource AncestorType=Button},Path=Foreground}" StrokeThickness="1" /> </Grid> - </Button> + </local:ButtonEx> <Grid Grid.Column="0" Grid.ColumnSpan="4" Grid.Row="0" Visibility="{Binding IsVariant,Mode=OneTime,Converter={StaticResource BoolToVisibilityConverter},FallbackValue=Collapsed}"> <Grid.ColumnDefinitions> @@ -1592,7 +1592,7 @@ <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> - <Button Name="removeVariant" Grid.Column="0" Command="{Binding RemoveVariationCommand,Mode=OneTime}" Style="{StaticResource VariantButton}" ToolTip="{x:Static prop:Resources.RemoveVariant}" AutomationProperties.Name="{x:Static prop:Resources.RemoveVariant}"> + <local:ButtonEx Name="removeVariant" Grid.Column="0" Command="{Binding RemoveVariationCommand,Mode=OneTime}" Style="{StaticResource VariantButton}" ToolTip="{x:Static prop:Resources.RemoveVariant}" AutomationProperties.Name="{x:Static prop:Resources.RemoveVariant}"> <Grid RenderTransformOrigin="0.5,0.5" Width="6" Height="6" VerticalAlignment="Center" HorizontalAlignment="Center"> <Grid.RenderTransform> <RotateTransform Angle="45" /> @@ -1601,7 +1601,7 @@ <Line X1="0" X2="6" Y1="3" Y2="3" Stroke="{Binding RelativeSource={RelativeSource AncestorType=Button},Path=Foreground}" StrokeThickness="1" /> <Line X1="3" X2="3" Y1="0" Y2="6" Stroke="{Binding RelativeSource={RelativeSource AncestorType=Button},Path=Foreground}" StrokeThickness="1" /> </Grid> - </Button> + </local:ButtonEx> <ItemsControl Margin="5,2,0,2" Name="variationsList" Grid.Column="1" ItemsSource="{Binding Variation,Mode=OneTime}" Focusable="False"> <ItemsControl.ItemsPanel> diff --git a/Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj b/Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj index f12fb1b..3aebf5b 100644 --- a/Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj +++ b/Xamarin.PropertyEditing.Windows/Xamarin.PropertyEditing.Windows.csproj @@ -59,6 +59,7 @@ <Compile Include="BrushEditorControl.cs" /> <Compile Include="BrushTabbedEditorControl.cs" /> <Compile Include="BrushToDarknessConverter.cs" /> + <Compile Include="ButtonEx.cs" /> <Compile Include="ByteToDoubleConverter.cs" /> <Compile Include="CategoryExpander.cs" /> <Compile Include="CollectionEditor.cs" /> |