<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">

    <Style x:Key="UWPFocusVisualStyle">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Border
                        Margin="-2"
                        BorderBrush="{DynamicResource PrimaryForegroundBrush}"
                        BorderThickness="2"
                        CornerRadius="4" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <DropShadowEffect
        x:Key="CardDropShadow"
        BlurRadius="6"
        Opacity="0.24"
        ShadowDepth="1" />

    <Style x:Key="MonitorItemContainerStyle" TargetType="ui:GridViewItem">
        <Setter Property="Background" Value="{DynamicResource LayoutItemBackgroundBrush}" />
        <Setter Property="IsSelected" Value="{Binding Selected, Mode=OneWay}" />
        <Setter Property="AutomationProperties.Name" Value="{Binding AccessibleName}" />
        <Setter Property="AutomationProperties.HelpText" Value="{Binding AccessibleHelpText}" />
        <Setter Property="KeyboardNavigation.TabNavigation" Value="Local" />
        <Setter Property="MinWidth" Value="0" />
        <Setter Property="MinHeight" Value="0" />
        <Setter Property="CornerRadius" Value="4" />
        <Setter Property="Margin" Value="8" />
        <Setter Property="UseSystemFocusVisuals" Value="{DynamicResource UseSystemFocusVisuals}" />
        <Setter Property="FocusVisualMargin" Value="-2" />
        <Setter Property="FocusVisualStyle" Value="{DynamicResource UWPFocusVisualStyle}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ui:GridViewItem">
                    <Border
                        x:Name="ContentBorder"
                        Width="{Binding DisplayWidth}"
                        Height="{Binding DisplayHeight}"
                        Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}"
                        CornerRadius="{TemplateBinding CornerRadius}"
                        Effect="{StaticResource CardDropShadow}"
                        SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                        <VisualStateManager.CustomVisualStateManager>
                            <ui:SimpleVisualStateManager />
                        </VisualStateManager.CustomVisualStateManager>

                        <Grid>
                            <ContentPresenter
                                x:Name="ContentPresenter"
                                Margin="{TemplateBinding Padding}"
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                            <Border
                                x:Name="BorderRectangle"
                                BorderBrush="{DynamicResource SystemControlHighlightListAccentLowBrush}"
                                BorderThickness="2"
                                CornerRadius="4"
                                IsHitTestVisible="False"
                                Opacity="0" />
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <!--  Focused  -->
                        <Trigger Property="ui:FocusVisualHelper.ShowFocusVisual" Value="True">
                            <Setter TargetName="BorderRectangle" Property="Visibility" Value="Collapsed" />
                        </Trigger>

                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding Selected}" Value="True" />

                            </MultiDataTrigger.Conditions>
                            <Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource SystemControlHighlightAccentBrush}" />
                            <Setter TargetName="BorderRectangle" Property="Opacity" Value="1" />
                            <Setter TargetName="BorderRectangle" Property="BorderBrush" Value="{DynamicResource SystemControlHighlightAccentBrush}" />
                        </MultiDataTrigger>

                        <!--  PointerOver  -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="True" />
                                <Condition Property="IsSelected" Value="False" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="BorderRectangle" Property="Opacity" Value="1" />
                            <Setter TargetName="BorderRectangle" Property="BorderBrush" Value="{DynamicResource SystemControlHighlightListLowBrush}" />
                            <Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource SystemControlForegroundBaseHighBrush}" />
                            <Setter Property="ui:FocusVisualHelper.FocusVisualSecondaryBrush" Value="{DynamicResource SystemControlHighlightListLowBrush}" />
                            <Setter Property="ui:FocusVisualHelper.FocusVisualSecondaryThickness" Value="2" />
                        </MultiTrigger>
                        <!--  Selected  -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="False" />
                                <Condition Property="IsSelected" Value="True" />
                            </MultiTrigger.Conditions>

                            <!--<Setter TargetName="BorderRectangle"
                                        Property="Opacity"
                                        Value="1" />
                                <Setter TargetName="BorderRectangle"
                                        Property="Stroke"
                                        Value="{DynamicResource SystemControlHighlightAccentBrush}" />
                                <Setter TargetName="ContentPresenter"
                                        Property="TextElement.Foreground"
                                        Value="{DynamicResource SystemControlHighlightAccentBrush}" />
                                <Setter Property="ui:FocusVisualHelper.FocusVisualSecondaryBrush"
                                        Value="{DynamicResource SystemControlHighlightAccentBrush}" />
                                <Setter Property="ui:FocusVisualHelper.FocusVisualSecondaryThickness"
                                        Value="2" />-->

                        </MultiTrigger>
                        <!--  PointerOverSelected  -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="True" />
                                <Condition Property="IsSelected" Value="True" />
                            </MultiTrigger.Conditions>

                            <Setter TargetName="BorderRectangle" Property="Opacity" Value="1" />
                            <Setter TargetName="BorderRectangle" Property="BorderBrush" Value="{DynamicResource SystemControlHighlightListAccentMediumBrush}" />
                            <Setter Property="ui:FocusVisualHelper.FocusVisualSecondaryBrush" Value="{DynamicResource SystemControlHighlightListAccentMediumBrush}" />
                            <Setter Property="ui:FocusVisualHelper.FocusVisualSecondaryThickness" Value="2" />

                        </MultiTrigger>
                        <!--  Disabled  -->
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="ContentBorder" Property="Opacity" Value="{DynamicResource ListViewItemDisabledThemeOpacity}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="LayoutItemContainerStyle" TargetType="ui:GridViewItem">
        <Setter Property="Background" Value="{DynamicResource LayoutItemBackgroundBrush}" />
        <Setter Property="IsSelected" Value="{Binding IsApplied, Mode=OneWay}" />
        <Setter Property="AutomationProperties.Name" Value="{Binding Name}" />
        <Setter Property="AutomationProperties.AutomationId" Value="{Binding AutomationId}" />
        <Setter Property="KeyboardNavigation.TabNavigation" Value="Local" />
        <!--<Setter Property="IsHoldingEnabled" Value="True" />-->
        <Setter Property="CornerRadius" Value="4" />
        <Setter Property="Margin" Value="8" />
        <Setter Property="UseSystemFocusVisuals" Value="{DynamicResource UseSystemFocusVisuals}" />
        <Setter Property="FocusVisualMargin" Value="-2" />
        <Setter Property="FocusVisualStyle" Value="{DynamicResource UWPFocusVisualStyle}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ui:GridViewItem">
                    <Border
                        x:Name="ContentBorder"
                        Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}"
                        CornerRadius="{TemplateBinding CornerRadius}"
                        Effect="{StaticResource CardDropShadow}"
                        SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                        <VisualStateManager.CustomVisualStateManager>
                            <ui:SimpleVisualStateManager />
                        </VisualStateManager.CustomVisualStateManager>

                        <Grid>
                            <ContentPresenter
                                x:Name="ContentPresenter"
                                Margin="{TemplateBinding Padding}"
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                            <Border
                                x:Name="BorderRectangle"
                                BorderBrush="{DynamicResource SystemControlHighlightListAccentLowBrush}"
                                BorderThickness="2"
                                CornerRadius="4"
                                IsHitTestVisible="False"
                                Opacity="0" />
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <!--  Focused  -->
                        <Trigger Property="ui:FocusVisualHelper.ShowFocusVisual" Value="True">
                            <Setter TargetName="BorderRectangle" Property="Visibility" Value="Collapsed" />
                        </Trigger>

                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsApplied}" Value="True" />

                            </MultiDataTrigger.Conditions>
                            <Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource SystemControlHighlightAccentBrush}" />
                            <Setter TargetName="BorderRectangle" Property="Opacity" Value="1" />
                            <Setter TargetName="BorderRectangle" Property="BorderBrush" Value="{DynamicResource SystemControlHighlightAccentBrush}" />
                        </MultiDataTrigger>

                        <!--  PointerOver  -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="True" />
                                <Condition Property="IsSelected" Value="False" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="BorderRectangle" Property="Opacity" Value="1" />
                            <Setter TargetName="BorderRectangle" Property="BorderBrush" Value="{DynamicResource SystemControlHighlightListLowBrush}" />
                            <Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource SystemControlForegroundBaseHighBrush}" />
                            <Setter Property="ui:FocusVisualHelper.FocusVisualSecondaryBrush" Value="{DynamicResource SystemControlHighlightListLowBrush}" />
                            <Setter Property="ui:FocusVisualHelper.FocusVisualSecondaryThickness" Value="2" />
                        </MultiTrigger>
                        <!--  Selected  -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="False" />
                                <Condition Property="IsSelected" Value="True" />
                            </MultiTrigger.Conditions>

                            <!--<Setter TargetName="BorderRectangle"
                                        Property="Opacity"
                                        Value="1" />
                                <Setter TargetName="BorderRectangle"
                                        Property="Stroke"
                                        Value="{DynamicResource SystemControlHighlightAccentBrush}" />
                                <Setter TargetName="ContentPresenter"
                                        Property="TextElement.Foreground"
                                        Value="{DynamicResource SystemControlHighlightAccentBrush}" />
                                <Setter Property="ui:FocusVisualHelper.FocusVisualSecondaryBrush"
                                        Value="{DynamicResource SystemControlHighlightAccentBrush}" />
                                <Setter Property="ui:FocusVisualHelper.FocusVisualSecondaryThickness"
                                        Value="2" />-->

                        </MultiTrigger>
                        <!--  PointerOverSelected  -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="True" />
                                <Condition Property="IsSelected" Value="True" />
                            </MultiTrigger.Conditions>

                            <Setter TargetName="BorderRectangle" Property="Opacity" Value="1" />
                            <Setter TargetName="BorderRectangle" Property="BorderBrush" Value="{DynamicResource SystemControlHighlightListAccentMediumBrush}" />
                            <Setter Property="ui:FocusVisualHelper.FocusVisualSecondaryBrush" Value="{DynamicResource SystemControlHighlightListAccentMediumBrush}" />
                            <Setter Property="ui:FocusVisualHelper.FocusVisualSecondaryThickness" Value="2" />

                        </MultiTrigger>
                        <!--  Disabled  -->
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="ContentBorder" Property="Opacity" Value="{DynamicResource ListViewItemDisabledThemeOpacity}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>