|
| 1 | +<!-- Copyright (c) 2024 Files Community. Licensed under the MIT License. See the LICENSE. --> |
| 2 | +<MenuFlyoutItem |
| 3 | + x:Class="Files.App.UserControls.MenuFlyoutItemWithOpacityIcon" |
| 4 | + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
| 5 | + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| 6 | + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
| 7 | + xmlns:local="using:Files.App.UserControls" |
| 8 | + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
| 9 | + d:DesignHeight="300" |
| 10 | + d:DesignWidth="400" |
| 11 | + HighContrastAdjustment="None" |
| 12 | + mc:Ignorable="d"> |
| 13 | + |
| 14 | + <MenuFlyoutItem.Style> |
| 15 | + <Style TargetType="local:MenuFlyoutItemWithOpacityIcon"> |
| 16 | + <Setter Property="Padding" Value="{ThemeResource MenuFlyoutItemThemePadding}" /> |
| 17 | + <Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" /> |
| 18 | + <Setter Property="Template"> |
| 19 | + <Setter.Value> |
| 20 | + <ControlTemplate TargetType="local:MenuFlyoutItemWithOpacityIcon"> |
| 21 | + |
| 22 | + <Grid |
| 23 | + x:Name="LayoutRoot" |
| 24 | + Margin="{StaticResource MenuFlyoutItemMargin}" |
| 25 | + Padding="{TemplateBinding Padding}" |
| 26 | + Background="{TemplateBinding Background}" |
| 27 | + BorderBrush="{TemplateBinding BorderBrush}" |
| 28 | + BorderThickness="{TemplateBinding BorderThickness}" |
| 29 | + CornerRadius="{StaticResource ControlCornerRadius}"> |
| 30 | + <Grid.ColumnDefinitions> |
| 31 | + <ColumnDefinition Width="*" /> |
| 32 | + <ColumnDefinition Width="Auto" /> |
| 33 | + </Grid.ColumnDefinitions> |
| 34 | + |
| 35 | + <Viewbox |
| 36 | + x:Name="IconRoot" |
| 37 | + Width="16" |
| 38 | + Height="16" |
| 39 | + HorizontalAlignment="Left" |
| 40 | + VerticalAlignment="Center" |
| 41 | + Visibility="Collapsed"> |
| 42 | + <ContentPresenter x:Name="IconContent" Content="{TemplateBinding Icon}" /> |
| 43 | + </Viewbox> |
| 44 | + |
| 45 | + <Viewbox |
| 46 | + Width="16" |
| 47 | + Height="16" |
| 48 | + Margin="0" |
| 49 | + HorizontalAlignment="Left" |
| 50 | + VerticalAlignment="Center"> |
| 51 | + <local:OpacityIcon Style="{TemplateBinding OpacityStyle}" /> |
| 52 | + </Viewbox> |
| 53 | + |
| 54 | + <TextBlock |
| 55 | + x:Name="TextBlock" |
| 56 | + HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" |
| 57 | + VerticalAlignment="{TemplateBinding VerticalContentAlignment}" |
| 58 | + Foreground="{TemplateBinding Foreground}" |
| 59 | + Text="{TemplateBinding Text}" |
| 60 | + TextTrimming="Clip" /> |
| 61 | + |
| 62 | + <TextBlock |
| 63 | + x:Name="KeyboardAcceleratorTextBlock" |
| 64 | + Grid.Column="1" |
| 65 | + MinWidth="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.KeyboardAcceleratorTextMinWidth}" |
| 66 | + Margin="24,0,0,0" |
| 67 | + HorizontalAlignment="Right" |
| 68 | + VerticalAlignment="{TemplateBinding VerticalContentAlignment}" |
| 69 | + AutomationProperties.AccessibilityView="Raw" |
| 70 | + Foreground="{ThemeResource MenuFlyoutItemKeyboardAcceleratorTextForeground}" |
| 71 | + Style="{ThemeResource CaptionTextBlockStyle}" |
| 72 | + Text="{TemplateBinding KeyboardAcceleratorTextOverride}" |
| 73 | + Visibility="Collapsed" /> |
| 74 | + |
| 75 | + <VisualStateManager.VisualStateGroups> |
| 76 | + <VisualStateGroup x:Name="CommonStates"> |
| 77 | + <VisualState x:Name="Normal" /> |
| 78 | + <VisualState x:Name="PointerOver"> |
| 79 | + <VisualState.Setters> |
| 80 | + <Setter Target="LayoutRoot.Background" Value="{ThemeResource MenuFlyoutItemBackgroundPointerOver}" /> |
| 81 | + <Setter Target="TextBlock.Foreground" Value="{ThemeResource MenuFlyoutItemForegroundPointerOver}" /> |
| 82 | + <Setter Target="IconContent.Foreground" Value="{ThemeResource MenuFlyoutItemForegroundPointerOver}" /> |
| 83 | + <Setter Target="KeyboardAcceleratorTextBlock.Foreground" Value="{ThemeResource MenuFlyoutItemKeyboardAcceleratorTextForegroundPointerOver}" /> |
| 84 | + </VisualState.Setters> |
| 85 | + </VisualState> |
| 86 | + <VisualState x:Name="Pressed"> |
| 87 | + <VisualState.Setters> |
| 88 | + <Setter Target="LayoutRoot.Background" Value="{ThemeResource MenuFlyoutItemBackgroundPressed}" /> |
| 89 | + <Setter Target="TextBlock.Foreground" Value="{ThemeResource MenuFlyoutItemForegroundPressed}" /> |
| 90 | + <Setter Target="IconContent.Foreground" Value="{ThemeResource MenuFlyoutItemForegroundPressed}" /> |
| 91 | + <Setter Target="KeyboardAcceleratorTextBlock.Foreground" Value="{ThemeResource MenuFlyoutItemKeyboardAcceleratorTextForegroundPressed}" /> |
| 92 | + </VisualState.Setters> |
| 93 | + </VisualState> |
| 94 | + <VisualState x:Name="Disabled"> |
| 95 | + <VisualState.Setters> |
| 96 | + <Setter Target="LayoutRoot.Background" Value="{ThemeResource MenuFlyoutItemBackgroundDisabled}" /> |
| 97 | + <Setter Target="TextBlock.Foreground" Value="{ThemeResource MenuFlyoutItemForegroundDisabled}" /> |
| 98 | + <Setter Target="IconContent.Foreground" Value="{ThemeResource MenuFlyoutItemForegroundDisabled}" /> |
| 99 | + <Setter Target="KeyboardAcceleratorTextBlock.Foreground" Value="{ThemeResource MenuFlyoutItemKeyboardAcceleratorTextForegroundDisabled}" /> |
| 100 | + </VisualState.Setters> |
| 101 | + </VisualState> |
| 102 | + </VisualStateGroup> |
| 103 | + <VisualStateGroup x:Name="CheckPlaceholderStates"> |
| 104 | + <VisualState x:Name="NoPlaceholder" /> |
| 105 | + <VisualState x:Name="CheckPlaceholder"> |
| 106 | + <VisualState.Setters> |
| 107 | + <Setter Target="TextBlock.Margin" Value="{ThemeResource MenuFlyoutItemPlaceholderThemeThickness}" /> |
| 108 | + </VisualState.Setters> |
| 109 | + </VisualState> |
| 110 | + <VisualState x:Name="IconPlaceholder"> |
| 111 | + <VisualState.Setters> |
| 112 | + <Setter Target="TextBlock.Margin" Value="{ThemeResource MenuFlyoutItemPlaceholderThemeThickness}" /> |
| 113 | + <Setter Target="IconRoot.Visibility" Value="Visible" /> |
| 114 | + </VisualState.Setters> |
| 115 | + </VisualState> |
| 116 | + <VisualState x:Name="CheckAndIconPlaceholder"> |
| 117 | + <VisualState.Setters> |
| 118 | + <Setter Target="TextBlock.Margin" Value="{ThemeResource MenuFlyoutItemDoublePlaceholderThemeThickness}" /> |
| 119 | + <Setter Target="IconRoot.Margin" Value="{ThemeResource MenuFlyoutItemPlaceholderThemeThickness}" /> |
| 120 | + <Setter Target="IconRoot.Visibility" Value="Visible" /> |
| 121 | + </VisualState.Setters> |
| 122 | + </VisualState> |
| 123 | + </VisualStateGroup> |
| 124 | + <!-- Narrow padding is only applied when flyout was invoked with pen, mouse or keyboard. --> |
| 125 | + <!-- Default padding is applied for all other cases including touch. --> |
| 126 | + <VisualStateGroup x:Name="PaddingSizeStates"> |
| 127 | + <VisualState x:Name="DefaultPadding" /> |
| 128 | + <VisualState x:Name="NarrowPadding"> |
| 129 | + <Storyboard> |
| 130 | + <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="Padding"> |
| 131 | + <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource MenuFlyoutItemThemePaddingNarrow}" /> |
| 132 | + </ObjectAnimationUsingKeyFrames> |
| 133 | + </Storyboard> |
| 134 | + </VisualState> |
| 135 | + </VisualStateGroup> |
| 136 | + <VisualStateGroup x:Name="KeyboardAcceleratorTextVisibility"> |
| 137 | + <VisualState x:Name="KeyboardAcceleratorTextCollapsed" /> |
| 138 | + <VisualState x:Name="KeyboardAcceleratorTextVisible"> |
| 139 | + <VisualState.Setters> |
| 140 | + <Setter Target="KeyboardAcceleratorTextBlock.Visibility" Value="Visible" /> |
| 141 | + </VisualState.Setters> |
| 142 | + </VisualState> |
| 143 | + </VisualStateGroup> |
| 144 | + </VisualStateManager.VisualStateGroups> |
| 145 | + </Grid> |
| 146 | + </ControlTemplate> |
| 147 | + </Setter.Value> |
| 148 | + </Setter> |
| 149 | + </Style> |
| 150 | + </MenuFlyoutItem.Style> |
| 151 | +</MenuFlyoutItem> |
0 commit comments