CardPanel.xaml 4.2 KB
Newer Older
R
Richasy 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Richasy.Bili.App.Controls">

    <SolidColorBrush
        x:Key="CardBackgroundFillColorPressedBrush"
        Opacity="0.8"
        Color="{StaticResource CardBackgroundFillColorSecondary}" />

    <Style TargetType="local:CardPanel">
        <Setter Property="Background" Value="{ThemeResource CardBackgroundFillColorDefaultBrush}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="Padding" Value="0" />
        <Setter Property="CornerRadius" Value="{StaticResource ControlCornerRadius}" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="UseSystemFocusVisuals" Value="True" />
        <Setter Property="AutomationProperties.LocalizedControlType" Value="Card" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:CardPanel">
                    <Grid x:Name="RootContainer">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />

                                <VisualState x:Name="PointerOver">
                                    <VisualState.Setters>
                                        <Setter Target="HostContainer.Background" Value="{ThemeResource CardBackgroundFillColorSecondaryBrush}" />
                                    </VisualState.Setters>
                                    <VisualState.Storyboard>
                                        <Storyboard>
                                            <PointerUpThemeAnimation Storyboard.TargetName="HostContainer" />
                                            <PointerUpThemeAnimation Storyboard.TargetName="ContentPresenter" />
                                        </Storyboard>
                                    </VisualState.Storyboard>
                                </VisualState>

                                <VisualState x:Name="Pressed">
                                    <VisualState.Setters>
                                        <Setter Target="HostContainer.Background" Value="{ThemeResource CardBackgroundFillColorPressedBrush}" />
                                    </VisualState.Setters>
                                    <VisualState.Storyboard>
                                        <Storyboard>
                                            <PointerDownThemeAnimation Storyboard.TargetName="HostContainer" />
                                            <PointerDownThemeAnimation Storyboard.TargetName="ContentPresenter" />
                                        </Storyboard>
                                    </VisualState.Storyboard>
                                </VisualState>

                                <VisualState x:Name="Disabled" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>

                        <Grid
                            x:Name="HostContainer"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            CornerRadius="{TemplateBinding CornerRadius}" />
                        <ContentPresenter
                            x:Name="ContentPresenter"
                            HorizontalAlignment="Stretch"
                            VerticalAlignment="Stretch"
                            HorizontalContentAlignment="Stretch"
                            VerticalContentAlignment="Stretch"
                            Content="{TemplateBinding Content}"
                            ContentTemplate="{TemplateBinding ContentTemplate}" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>