Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix splitbutton keyboard accessability. #840

Merged
merged 2 commits into from
Jan 11, 2022
Merged
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
57 changes: 9 additions & 48 deletions XamlControlsGallery/ControlPages/SplitButtonPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<Border x:Name="CurrentColor" Width="{StaticResource SwatchSize}" Height="{StaticResource SwatchSize}" Background="Green" Margin="0" CornerRadius="4,0,0,4"/>
<muxc:SplitButton.Flyout>
<Flyout Placement="Bottom">
<GridView>
<GridView ItemClick="GridView_ItemClick" IsItemClickEnabled="True">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsWrapGrid MaximumRowsOrColumns="3" Orientation="Horizontal"/>
Expand All @@ -31,55 +31,16 @@
<Setter Property="RadiusX" Value="4"/>
<Setter Property="RadiusY" Value="4"/>
</Style>
<Style TargetType="Button">
<Setter Property="Padding" Value="0"/>
<Setter Property="MinWidth" Value="0"/>
<Setter Property="MinHeight" Value="0"/>
<Setter Property="Margin" Value="6"/>
<Setter Property="CornerRadius" Value="{StaticResource ControlCornerRadius}"/>
</Style>
</GridView.Resources>
<GridView.Items>
<Button Click="ColorButton_Click" AutomationProperties.Name="Red">
<Button.Content>
<Rectangle Fill="Red"/>
</Button.Content>
</Button>
<Button Click="ColorButton_Click" AutomationProperties.Name="Orange">
<Button.Content>
<Rectangle Fill="Orange"/>
</Button.Content>
</Button>
<Button Click="ColorButton_Click" AutomationProperties.Name="Yellow">
<Button.Content>
<Rectangle Fill="Yellow"/>
</Button.Content>
</Button>
<Button Click="ColorButton_Click" AutomationProperties.Name="Green">
<Button.Content>
<Rectangle Fill="Green"/>
</Button.Content>
</Button>
<Button Click="ColorButton_Click" AutomationProperties.Name="Blue">
<Button.Content>
<Rectangle Fill="Blue"/>
</Button.Content>
</Button>
<Button Click="ColorButton_Click" AutomationProperties.Name="Indigo">
<Button.Content>
<Rectangle Fill="Indigo"/>
</Button.Content>
</Button>
<Button Click="ColorButton_Click" AutomationProperties.Name="Violet">
<Button.Content>
<Rectangle Fill="Violet"/>
</Button.Content>
</Button>
<Button Click="ColorButton_Click" AutomationProperties.Name="Gray">
<Button.Content>
<Rectangle Fill="Gray"/>
</Button.Content>
</Button>
<Rectangle Fill="Red"/>
<Rectangle Fill="Orange"/>
<Rectangle Fill="Yellow"/>
<Rectangle Fill="Green"/>
<Rectangle Fill="Blue"/>
<Rectangle Fill="Indigo"/>
<Rectangle Fill="Violet"/>
<Rectangle Fill="Gray"/>
</GridView.Items>
</GridView>

Expand Down
10 changes: 4 additions & 6 deletions XamlControlsGallery/ControlPages/SplitButtonPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Shapes;

namespace AppUIBasics.ControlPages
{
Expand All @@ -19,13 +20,10 @@ public SplitButtonPage()
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Tempor commodo ullamcorper a lacus.");
}

private void ColorButton_Click(object sender, RoutedEventArgs e)
private void GridView_ItemClick(object sender, ItemClickEventArgs e)
{
// Extract the color of the button that was clicked.
Button clickedColor = (Button)sender;
var rectangle = (Windows.UI.Xaml.Shapes.Rectangle)clickedColor.Content;
var color = ((Windows.UI.Xaml.Media.SolidColorBrush)rectangle.Fill).Color;

var rect = (Rectangle)e.ClickedItem;
var color = ((SolidColorBrush)rect.Fill).Color;
myRichEditBox.Document.Selection.CharacterFormat.ForegroundColor = color;
CurrentColor.Background = new SolidColorBrush(color);

Expand Down