<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes">
    <Style x:Key="SidebarListBoxItem" TargetType="{x:Type ListBoxItem}" BasedOn="{StaticResource MaterialDesignToolToggleListBoxItem}">
        <Setter Property="Padding" Value="8" />
        <Setter Property="Margin" Value="6 1" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Margin="{TemplateBinding Margin}"
                            ClipToBounds="{TemplateBinding ClipToBounds}"
                            Cursor="Hand">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.3" To="Normal">
                                        <VisualTransition.GeneratedEasingFunction>
                                            <CircleEase EasingMode="EaseOut" />
                                        </VisualTransition.GeneratedEasingFunction>
                                    </VisualTransition>
                                </VisualStateGroup.Transitions>
                                <VisualState Name="Normal" />
                                <VisualState Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="MouseOverBorder" Storyboard.TargetProperty="Opacity"
                                                         To="0.03" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState Name="Disabled" />
                            </VisualStateGroup>
                            <VisualStateGroup Name="SelectionStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition From="*" To="Selected">
                                        <Storyboard>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="SelectedBackgroundBorder">
                                                <EasingDoubleKeyFrame KeyTime="0" Value="1" />
                                            </DoubleAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualTransition>
                                    <VisualTransition From="*" To="SelectedUnfocused">
                                        <Storyboard>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="SelectedBackgroundBorder">
                                                <EasingDoubleKeyFrame KeyTime="0" Value="1" />
                                            </DoubleAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualTransition>
                                    <VisualTransition From="Selected" To="Unselected">
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="SelectedBackgroundBorder"
                                                             Storyboard.TargetProperty="Opacity"
                                                             To="0" Duration="0" />
                                        </Storyboard>
                                    </VisualTransition>
                                </VisualStateGroup.Transitions>
                                <VisualState Name="Selected">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="SelectedBackgroundBorder"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="1" Duration="0" />
                                        <DoubleAnimation Storyboard.TargetName="SelectedBorder"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="1" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState Name="Unselected" />
                                <VisualState Name="SelectedUnfocused">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="SelectedBackgroundBorder"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="1" Duration="0" />
                                        <DoubleAnimation Storyboard.TargetName="SelectedBorder"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="1" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid>
                            <Grid.OpacityMask>
                                <VisualBrush>
                                    <VisualBrush.Visual>
                                        <Border Background="Black"
                                                CornerRadius="4"
                                                Width="{Binding ActualWidth, RelativeSource={RelativeSource AncestorType=Grid}}"
                                                Height="{Binding ActualHeight, RelativeSource={RelativeSource AncestorType=Grid}}" />
                                    </VisualBrush.Visual>
                                </VisualBrush>
                            </Grid.OpacityMask>
                            <Border x:Name="MouseOverBorder"
                                    Opacity="0"
                                    Background="{TemplateBinding Foreground, Converter={StaticResource BrushRoundConverter}}" />
                            <Border x:Name="SelectedBackgroundBorder"
                                    Opacity="0"
                                    Background="{DynamicResource MaterialDesignDivider}" />
                            <materialDesign:Ripple x:Name="Ripple" Feedback="{TemplateBinding Foreground, Converter={StaticResource BrushRoundConverter}}"
                                                   Opacity=".82"
                                                   Focusable="False"
                                                   Content="{TemplateBinding Content}"
                                                   ContentTemplate="{TemplateBinding ContentTemplate}"
                                                   ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
                                                   SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                                   HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                   VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                                   Padding="{TemplateBinding Padding}" />
                            <Border x:Name="SelectedBorder"
                                    Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=ListBox}, Path=SelectionMode, Converter={StaticResource EqualityToVisibilityConverter}, ConverterParameter={x:Static SelectionMode.Extended}, Mode=OneWay}"
                                    Opacity="0"
                                    BorderThickness="0"
                                    BorderBrush="{DynamicResource MaterialDesignDivider}" />
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter TargetName="Ripple" Property="Opacity" Value=".92" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Opacity" Value=".56" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>