<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ui="http://schemas.modernwpf.com/2019"
    xmlns:local="clr-namespace:ModernWpf.Controls">

    <Style TargetType="local:ListViewItem">
        <Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" />
        <Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
        <Setter Property="BorderBrush" Value="{x:Null}" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Foreground" Value="{DynamicResource SystemControlForegroundBaseHighBrush}" />
        <Setter Property="KeyboardNavigation.TabNavigation" Value="Local" />
        <!--<Setter Property="IsHoldingEnabled" Value="True" />-->
        <Setter Property="Padding" Value="12,0,12,0" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="MinWidth" Value="{DynamicResource ListViewItemMinWidth}" />
        <Setter Property="MinHeight" Value="{DynamicResource ListViewItemMinHeight}" />
        <Setter Property="UseSystemFocusVisuals" Value="{DynamicResource UseSystemFocusVisuals}" />
        <Setter Property="FocusVisualMargin" Value="0" />
        <Setter Property="FocusVisualStyle" Value="{DynamicResource {x:Static SystemParameters.FocusVisualStyleKey}}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:ListViewItem">
                    <ControlTemplate.Resources>
                        <StreamGeometry x:Key="CheckMark">M 17.939453 5.439453 L 7.5 15.888672 L 2.060547 10.439453 L 2.939453 9.560547 L 7.5 14.111328 L 17.060547 4.560547 Z</StreamGeometry>
                    </ControlTemplate.Resources>
                    <Border
                        x:Name="ContentBorder"
                        Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}"
                        CornerRadius="{TemplateBinding CornerRadius}"
                        SnapsToDevicePixels="True">
                        <VisualStateManager.CustomVisualStateManager>
                            <ui:SimpleVisualStateManager />
                        </VisualStateManager.CustomVisualStateManager>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="MultiSelectStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition From="MultiSelectDisabled" To="MultiSelectEnabled">
                                        <Storyboard>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="MultiSelectCheckBoxTransform" Storyboard.TargetProperty="X">
                                                <EasingDoubleKeyFrame KeyTime="0:0:0" Value="-32" />
                                                <SplineDoubleKeyFrame KeyTime="0:0:0.333" Value="0" KeySpline="0.1,0.9,0.2,1" />
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="MultiSelectClipTransform" Storyboard.TargetProperty="X">
                                                <EasingDoubleKeyFrame KeyTime="0:0:0" Value="32" />
                                                <SplineDoubleKeyFrame KeyTime="0:0:0.333" Value="0" KeySpline="0.1,0.9,0.2,1" />
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenterTranslateTransform" Storyboard.TargetProperty="X">
                                                <EasingDoubleKeyFrame KeyTime="0:0:0" Value="-32" />
                                                <SplineDoubleKeyFrame KeyTime="0:0:0.333" Value="0" KeySpline="0.1,0.9,0.2,1" />
                                            </DoubleAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MultiSelectSquare" Storyboard.TargetProperty="Visibility">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MultiSelectCheck" Storyboard.TargetProperty="Visibility">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ThicknessAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenterGrid" Storyboard.TargetProperty="Margin">
                                                <DiscreteThicknessKeyFrame KeyTime="0" Value="32,0,0,0" />
                                            </ThicknessAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualTransition>
                                    <VisualTransition From="MultiSelectEnabled" To="MultiSelectDisabled">
                                        <Storyboard>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="MultiSelectCheckBoxTransform" Storyboard.TargetProperty="X">
                                                <EasingDoubleKeyFrame KeyTime="0:0:0" Value="0" />
                                                <SplineDoubleKeyFrame KeyTime="0:0:0.333" Value="-32" KeySpline="0.1,0.9,0.2,1" />
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="MultiSelectClipTransform" Storyboard.TargetProperty="X">
                                                <EasingDoubleKeyFrame KeyTime="0:0:0" Value="0" />
                                                <SplineDoubleKeyFrame KeyTime="0:0:0.333" Value="32" KeySpline="0.1,0.9,0.2,1" />
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenterTranslateTransform" Storyboard.TargetProperty="X">
                                                <EasingDoubleKeyFrame KeyTime="0:0:0" Value="32" />
                                                <SplineDoubleKeyFrame KeyTime="0:0:0.333" Value="0" KeySpline="0.1,0.9,0.2,1" />
                                            </DoubleAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MultiSelectSquare" Storyboard.TargetProperty="Visibility">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}" />
                                                <DiscreteObjectKeyFrame KeyTime="0:0:0.333" Value="{x:Static Visibility.Collapsed}" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualTransition>
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="MultiSelectDisabled">
                                    <Storyboard>
                                        <DoubleAnimation
                                            Storyboard.TargetName="MultiSelectCheckBoxTransform"
                                            Storyboard.TargetProperty="X"
                                            From="0"
                                            To="-32"
                                            Duration="0" />
                                        <DoubleAnimation
                                            Storyboard.TargetName="MultiSelectClipTransform"
                                            Storyboard.TargetProperty="X"
                                            From="0"
                                            To="32"
                                            Duration="0" />
                                        <DoubleAnimation
                                            Storyboard.TargetName="ContentPresenterTranslateTransform"
                                            Storyboard.TargetProperty="X"
                                            From="32"
                                            To="0"
                                            Duration="0" />
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MultiSelectSquare" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="MultiSelectEnabled">
                                    <Storyboard>
                                        <DoubleAnimation
                                            Storyboard.TargetName="MultiSelectCheckBoxTransform"
                                            Storyboard.TargetProperty="X"
                                            From="-32"
                                            To="0"
                                            Duration="0" />
                                        <DoubleAnimation
                                            Storyboard.TargetName="MultiSelectClipTransform"
                                            Storyboard.TargetProperty="X"
                                            From="32"
                                            To="0"
                                            Duration="0" />
                                        <DoubleAnimation
                                            Storyboard.TargetName="ContentPresenterTranslateTransform"
                                            Storyboard.TargetProperty="X"
                                            From="-32"
                                            To="0"
                                            Duration="0" />
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MultiSelectSquare" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MultiSelectCheck" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ThicknessAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenterGrid" Storyboard.TargetProperty="Margin">
                                            <DiscreteThicknessKeyFrame KeyTime="0" Value="32,0,0,0" />
                                        </ThicknessAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid>
                            <Rectangle
                                x:Name="BorderBackground"
                                IsHitTestVisible="False"
                                Fill="{DynamicResource ListViewItemBorderBackground}"
                                Opacity="0" />
                            <Grid
                                x:Name="ContentPresenterGrid"
                                Background="Transparent"
                                Margin="0,0,0,0">
                                <Grid.RenderTransform>
                                    <TranslateTransform x:Name="ContentPresenterTranslateTransform" />
                                </Grid.RenderTransform>
                                <ContentPresenter
                                    x:Name="ContentPresenter"
                                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                    Margin="{TemplateBinding Padding}"
                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                            </Grid>
                            <Border
                                x:Name="MultiSelectSquare"
                                BorderBrush="{DynamicResource SystemControlForegroundBaseMediumHighBrush}"
                                BorderThickness="2"
                                Width="20"
                                Height="20"
                                Margin="12,0,0,0"
                                VerticalAlignment="Center"
                                HorizontalAlignment="Left"
                                Visibility="Collapsed">
                                <Border.Clip>
                                    <RectangleGeometry Rect="0,0,20,20">
                                        <RectangleGeometry.Transform>
                                            <TranslateTransform x:Name="MultiSelectClipTransform" />
                                        </RectangleGeometry.Transform>
                                    </RectangleGeometry>
                                </Border.Clip>
                                <Border.RenderTransform>
                                    <TranslateTransform x:Name="MultiSelectCheckBoxTransform" />
                                </Border.RenderTransform>
                                <ui:FontIconFallback
                                    x:Name="MultiSelectCheck"
                                    FontFamily="{DynamicResource SymbolThemeFontFamily}"
                                    Data="{StaticResource CheckMark}"
                                    FontSize="16"
                                    Foreground="{DynamicResource ListViewItemCheckBrush}"
                                    Visibility="Collapsed"
                                    Opacity="0" />
                            </Border>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="True" />
                                <Condition Property="IsSelected" Value="False" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="BorderBackground" Property="Opacity" Value="1" />
                            <Setter TargetName="BorderBackground" Property="Fill" Value="{DynamicResource SystemControlHighlightListLowBrush}" />
                            <Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource SystemControlHighlightAltBaseHighBrush}" />
                            <Setter TargetName="MultiSelectSquare" Property="BorderBrush" Value="{DynamicResource SystemControlHighlightAltBaseHighBrush}" />
                            <Setter TargetName="MultiSelectCheck" Property="Foreground" Value="{DynamicResource SystemControlHighlightAltBaseHighBrush}" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="False" />
                                <Condition Property="IsSelected" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="MultiSelectCheck" Property="Opacity" Value="1" />
                            <Setter TargetName="BorderBackground" Property="Opacity" Value="1" />
                            <Setter TargetName="BorderBackground" Property="Fill" Value="{DynamicResource SystemControlHighlightListAccentLowBrush}" />
                            <Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource SystemControlHighlightAltBaseHighBrush}" />
                            <Setter TargetName="MultiSelectSquare" Property="BorderBrush" Value="{DynamicResource SystemControlHighlightAltBaseHighBrush}" />
                            <Setter TargetName="MultiSelectCheck" Property="Foreground" Value="{DynamicResource SystemControlHighlightAltBaseHighBrush}" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="True" />
                                <Condition Property="IsSelected" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="MultiSelectCheck" Property="Opacity" Value="1" />
                            <Setter TargetName="BorderBackground" Property="Opacity" Value="1" />
                            <Setter TargetName="BorderBackground" Property="Fill" Value="{DynamicResource SystemControlHighlightListAccentMediumBrush}" />
                            <Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource SystemControlHighlightAltBaseHighBrush}" />
                            <Setter TargetName="MultiSelectSquare" Property="BorderBrush" Value="{DynamicResource SystemControlHighlightAltBaseHighBrush}" />
                            <Setter TargetName="MultiSelectCheck" Property="Foreground" Value="{DynamicResource SystemControlHighlightAltBaseHighBrush}" />
                        </MultiTrigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="ContentBorder" Property="Opacity" Value="{DynamicResource ListViewItemDisabledThemeOpacity}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:ListView">
        <Setter Property="Padding" Value="0,0,0,10" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="KeyboardNavigation.TabNavigation" Value="Once" />
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
        <Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False" />
        <Setter Property="ScrollViewer.CanContentScroll" Value="true" />
        <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
        <Setter Property="UseSystemFocusVisuals" Value="{DynamicResource UseSystemFocusVisuals}" />
        <Setter Property="FocusVisualStyle" Value="{DynamicResource {x:Static SystemParameters.FocusVisualStyleKey}}" />
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <VirtualizingStackPanel Orientation="Vertical" />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:ListView">
                    <Border
                        BorderBrush="{TemplateBinding BorderBrush}"
                        Background="{TemplateBinding Background}"
                        BorderThickness="{TemplateBinding BorderThickness}"
                        CornerRadius="{TemplateBinding CornerRadius}"
                        SnapsToDevicePixels="True">
                        <ui:ScrollViewerEx
                            x:Name="ScrollViewer"
                            KeyboardNavigation.TabNavigation="{TemplateBinding KeyboardNavigation.TabNavigation}"
                            HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
                            VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
                            IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
                            Focusable="false">
                            <ItemsPresenter
                                Margin="{TemplateBinding Padding}"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </ui:ScrollViewerEx>
                    </Border>
                    <ControlTemplate.Triggers>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsGrouping" Value="true" />
                                <Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false" />
                            </MultiTrigger.Conditions>
                            <Setter Property="ScrollViewer.CanContentScroll" Value="false" />
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>