<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="using:Microsoft.Toolkit.Uwp.UI.Controls">

    <Style x:Key="HambugerMenuItemStyle" TargetType="ListViewItem">
        <Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseHighBrush}" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="MinHeight" Value="0"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="UseSystemFocusVisuals" Value="True" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListViewItem">
                    <Grid x:Name="LayoutRoot"
                          Background="{TemplateBinding Background}" 
                          Control.IsTemplateFocusTarget="True"
                          Height="40">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="PointerStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="PointerOver">
                                    <VisualState.Setters>
                                        <Setter Target="LayoutRoot.Background" Value="{ThemeResource SystemControlHighlightListLowBrush}" />
                                        <Setter Target="ContentPresenter.Foreground" Value="{ThemeResource SystemControlHighlightAltBaseHighBrush}" />
                                    </VisualState.Setters>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <VisualState.Setters>
                                        <Setter Target="LayoutRoot.Background" Value="{ThemeResource SystemControlHighlightListMediumBrush}" />
                                        <Setter Target="ContentPresenter.Foreground" Value="{ThemeResource SystemControlHighlightAltBaseHighBrush}" />
                                    </VisualState.Setters>
                                </VisualState>
                                <VisualState x:Name="Selected">
                                    <VisualState.Setters>
                                        <Setter Target="SelectionIndicator.Opacity" Value="1.0" />
                                    </VisualState.Setters>
                                </VisualState>
                                <VisualState x:Name="PointerOverSelected">
                                    <VisualState.Setters>
                                        <Setter Target="LayoutRoot.Background" Value="{ThemeResource SystemControlHighlightListLowBrush}" />
                                        <Setter Target="ContentPresenter.Foreground" Value="{ThemeResource SystemControlHighlightAltBaseHighBrush}" />
                                        <Setter Target="SelectionIndicator.Opacity" Value="1.0" />
                                    </VisualState.Setters>
                                </VisualState>
                                <VisualState x:Name="PressedSelected">
                                    <VisualState.Setters>
                                        <Setter Target="LayoutRoot.Background" Value="{ThemeResource SystemControlHighlightListMediumBrush}" />
                                        <Setter Target="ContentPresenter.Foreground" Value="{ThemeResource SystemControlHighlightAltBaseHighBrush}" />
                                        <Setter Target="SelectionIndicator.Opacity" Value="1.0" />
                                    </VisualState.Setters>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="DisabledStates">
                                <VisualState x:Name="Enabled" />
                                <VisualState x:Name="Disabled">
                                    <VisualState.Setters>
                                        <Setter Target="LayoutRoot.Opacity" Value="{ThemeResource ListViewItemDisabledThemeOpacity}" />
                                    </VisualState.Setters>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <!-- Wrap SelectionIndicator in a grid so that its offset is 0,0 - this enables the offset animation. -->
                        <Grid HorizontalAlignment="Left" VerticalAlignment="Center">
                            <Rectangle x:Name="SelectionIndicator"
                                       Fill="{ThemeResource SystemControlForegroundAccentBrush}"
                                       Height="24"
                                       Opacity="0.0"
                                       Width="6"/>
                        </Grid>
                        <ContentPresenter x:Name="ContentPresenter"
                                          Content="{TemplateBinding Content}"
                                          ContentTemplate="{TemplateBinding ContentTemplate}"
                                          ContentTransitions="{TemplateBinding ContentTransitions}"
                                          Grid.Column="1"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          Margin="{TemplateBinding Padding}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ControlTemplate x:Key="HamburgerMenuTemplate" TargetType="local:HamburgerMenu">
        <Grid>
            <SplitView x:Name="MainSplitView"
                                   CompactPaneLength="{TemplateBinding CompactPaneLength}"
                                   DisplayMode="{TemplateBinding DisplayMode}"
                                   IsPaneOpen="{Binding IsPaneOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                                   IsTabStop="False"
                                   OpenPaneLength="{TemplateBinding OpenPaneLength}"
                                   PaneBackground="{TemplateBinding PaneBackground}"
                                   PanePlacement="{TemplateBinding PanePlacement}">
                <SplitView.Pane>
                    <Grid x:Name="PaneGrid"
                                      FlowDirection="LeftToRight">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Grid Grid.Row="0"
                                          Height="{TemplateBinding HamburgerHeight}"
                                          Margin="0,0,0,8" />
                        <ListView x:Name="ButtonsListView"
                                              Grid.Row="1"
                                              Width="{TemplateBinding OpenPaneLength}"
                                              AutomationProperties.Name="Menu items"
                                              IsItemClickEnabled="True"
                                              ItemContainerStyle="{StaticResource HambugerMenuItemStyle}"
                                              ItemTemplate="{TemplateBinding ItemTemplate}"
                                              ItemTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                                              ItemsSource="{TemplateBinding ItemsSource}"
                                              ScrollViewer.VerticalScrollBarVisibility="Auto"
                                              SelectedIndex="{Binding SelectedIndex, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                                              SelectedItem="{Binding SelectedItem, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                                              SelectionMode="Single"
                                              TabIndex="1">
                        </ListView>
                        <ListView x:Name="OptionsListView"
                                              Grid.Row="2"
                                              Width="{TemplateBinding OpenPaneLength}"
                                              VerticalAlignment="Bottom"
                                              AutomationProperties.Name="Option items"
                                              IsItemClickEnabled="True"
                                              ItemContainerStyle="{StaticResource HambugerMenuItemStyle}"
                                              ItemTemplate="{TemplateBinding OptionsItemTemplate}"
                                              ItemTemplateSelector="{TemplateBinding OptionsItemTemplateSelector}"
                                              ItemsSource="{TemplateBinding OptionsItemsSource}"
                                              ScrollViewer.VerticalScrollBarVisibility="Disabled"
                                              SelectedIndex="{Binding SelectedOptionsIndex, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                                              SelectedItem="{Binding SelectedOptionsItem, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                                              SelectionMode="Single"
                                              TabIndex="2"
                                              Margin="0,20,0,8">
                        </ListView>
                    </Grid>
                </SplitView.Pane>
                <ContentPresenter x:Name="ContentPart"
                                              AutomationProperties.Name="Content"
                                              Content="{TemplateBinding Content}" />
            </SplitView>
            <Button x:Name="HamburgerButton"
                                Width="{TemplateBinding HamburgerWidth}"
                                Height="{TemplateBinding HamburgerHeight}"
                                Visibility="{TemplateBinding HamburgerVisibility}"
                                Margin="0,0,0,8"
                                Padding="0"
                                VerticalAlignment="Top"
                                AutomationProperties.Name="Main button"
                                Background="Transparent"
                                BorderThickness="0"
                                TabIndex="0">
                <ContentControl Margin="{TemplateBinding HamburgerMargin}"
                                            ContentTemplate="{TemplateBinding HamburgerMenuTemplate}"
                                            Foreground="{TemplateBinding PaneForeground}"
                                            IsTabStop="False" />
            </Button>
        </Grid>
    </ControlTemplate>

</ResourceDictionary>

