<?xml version="1.0" encoding="utf-8" ?>
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Microsoft.PowerToys.Common.UI.Controls"
    xmlns:tk="using:CommunityToolkit.WinUI"
    xmlns:tkcontrols="using:CommunityToolkit.WinUI.Controls">

    <Style BasedOn="{StaticResource DefaultShortcutWithTextLabelControlStyle}" TargetType="local:ShortcutWithTextLabelControl" />

    <Style x:Key="DefaultShortcutWithTextLabelControlStyle" TargetType="local:ShortcutWithTextLabelControl">
        <Setter Property="KeyVisualStyle" Value="{StaticResource DefaultKeyVisualStyle}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:ShortcutWithTextLabelControl">
                    <Grid ColumnSpacing="8">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <ItemsControl
                            x:Name="ShortcutsControl"
                            VerticalAlignment="Bottom"
                            AutomationProperties.AccessibilityView="Raw"
                            IsTabStop="False"
                            ItemsSource="{TemplateBinding Keys}">
                            <ItemsControl.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <StackPanel Orientation="Horizontal" Spacing="4" />
                                </ItemsPanelTemplate>
                            </ItemsControl.ItemsPanel>
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <StackPanel Orientation="Vertical">
                                        <local:KeyVisual
                                            tk:FrameworkElementExtensions.AncestorType="local:ShortcutWithTextLabelControl"
                                            AutomationProperties.AccessibilityView="Raw"
                                            Content="{Binding}"
                                            IsTabStop="False"
                                            Style="{Binding (tk:FrameworkElementExtensions.Ancestor).KeyVisualStyle, RelativeSource={RelativeSource Self}}" />
                                    </StackPanel>
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                        </ItemsControl>
                        <tkcontrols:MarkdownTextBlock
                            x:Name="LabelControl"
                            Grid.Column="1"
                            VerticalAlignment="Center"
                            Config="{TemplateBinding MarkdownConfig}"
                            Text="{TemplateBinding Text}" />
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="LabelPlacementStates">
                                <VisualState x:Name="LabelAfter" />
                                <VisualState x:Name="LabelBefore">
                                    <VisualState.Setters>
                                        <Setter Target="LabelControl.(Grid.Column)" Value="0" />
                                        <Setter Target="ShortcutsControl.(Grid.Column)" Value="1" />
                                    </VisualState.Setters>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
