<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:cache="clr-namespace:GitHub.UI.Helpers;assembly=GitHub.UI"
                    xmlns:ui="clr-namespace:GitHub.UI;assembly=GitHub.UI">

    <ResourceDictionary.MergedDictionaries>
        <cache:SharedDictionaryManager Source="pack://application:,,,/GitHub.UI;component/SharedDictionary.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="HyperLinkToggleButton" TargetType="ToggleButton">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ToggleButton">
                    <Grid>
                        <Border Background="Transparent"
                                BorderBrush="{TemplateBinding Foreground}">
                            <Border.Style>
                                <Style TargetType="Border">
                                    <Style.Triggers>
                                        <MultiDataTrigger>
                                            <MultiDataTrigger.Conditions>
                                                <Condition Binding="{Binding Path=IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
                                                <Condition Binding="{Binding Path=IsEnabled, RelativeSource={RelativeSource Self}}" Value="true"/>
                                                <Condition Binding="{Binding Path=IsChecked, RelativeSource={RelativeSource TemplatedParent}}" Value="false"/>
                                            </MultiDataTrigger.Conditions>
                                            <MultiDataTrigger.Setters>
                                                <Setter Property="BorderThickness" Value="0,0,0,1"/>
                                                <Setter Property="FrameworkElement.Cursor" Value="Hand"/>
                                            </MultiDataTrigger.Setters>
                                        </MultiDataTrigger>
                                        <DataTrigger Binding="{Binding Path=IsPressed, RelativeSource={RelativeSource TemplatedParent}}" Value="true">
                                            <Setter Property="BorderThickness" Value="0,0,0,1"/>
                                            <Setter Property="FrameworkElement.Cursor" Value="Hand"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </Border.Style>
                        </Border>
                        <Polygon Margin="2,0,0,3" 
                                 HorizontalAlignment="Right"
                                 VerticalAlignment="Bottom"
                                 Fill="{TemplateBinding Foreground}"
                                 Points="0,0 8,0 4,4 0,0"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type ui:LinkDropDown}">
        <Setter Property="Foreground" Value="{DynamicResource GitHubActionLinkItemBrush}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ui:LinkDropDown">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="14"/>
                        </Grid.ColumnDefinitions>

                        <ToggleButton Grid.ColumnSpan="2"
                                      Foreground="{TemplateBinding Foreground}"
                                      IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                                      Style="{StaticResource HyperLinkToggleButton}"
                                      Margin="0,0,0,1"/>
                        <ContentPresenter ContentTemplate="{TemplateBinding LinkItemTemplate}"
                                          Content="{TemplateBinding LinkItem}"
                                          ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          IsHitTestVisible="false"
                                          Margin="{TemplateBinding Padding}"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                            <ContentPresenter.Style>
                                <Style TargetType="ContentPresenter">
                                    <Style.Triggers>
                                        <Trigger Property="IsEnabled" Value="False">
                                            <Setter Property="Opacity" Value="0.5"/>
                                        </Trigger>
                                    </Style.Triggers>
                                </Style>
                            </ContentPresenter.Style>
                        </ContentPresenter>
                        <Popup Name="PART_Popup"
                               AllowsTransparency="True"
                               IsOpen="{TemplateBinding IsDropDownOpen}"
                               Placement="Bottom">
                            <Popup.Resources>
                                <Style BasedOn="{StaticResource {x:Type ComboBoxItem}}" TargetType="{x:Type ComboBoxItem}">
                                    <Setter Property="Foreground" Value="{DynamicResource GitHubButtonForegroundBrush}"/>
                                    <Setter Property="Padding" Value="3"/>
                                    <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                                </Style>
                            </Popup.Resources>
                            <Border Style="{DynamicResource GitHubComboBoxBorder}">
                                <DockPanel MinWidth="100" Style="{DynamicResource GitHubComboBoxDockPanelContainer}">
                                    <ScrollViewer VerticalScrollBarVisibility="Auto">
                                        <ItemsPresenter/>
                                    </ScrollViewer>
                                </DockPanel>
                            </Border>
                        </Popup>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>