UWP Xaml在哪里可以得到GridViewItem的dafault样式

p4tfgftt  于 2023-05-11  发布在  其他
关注(0)|答案(1)|浏览(115)

当我尝试在设计器中为GridViewItem使用“编辑样式”->“编辑副本”选项时,它为GridView而不是GridViewItem生成样式。那么我在哪里可以得到GridViewItem的默认样式呢?我期待修改一些属性从默认的风格改变外观和感觉GridViewItems。

wi3ka0sx

wi3ka0sx1#

您可以在Generic.xaml中获取GridViewItem的默认样式。
下面是一种快速访问Generic.xaml正确版本的方法。

选择ApplicationPageBackgroundThemeBrushType并键入F12,然后您将快速输入Generic.xaml文件的正确版本。然后在Generic.xaml文件中搜索GridViewItemRevealStyle,您将获得正确的默认样式GridViewItem

<Style TargetType="GridViewItem" x:Key="GridViewItemRevealStyle">
    <Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
    <Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
    <Setter Property="Background" Value="{ThemeResource GridViewItemBackground}" />
    <Setter Property="Foreground" Value="{ThemeResource GridViewItemForeground}" />
    <Setter Property="TabNavigation" Value="Local" />
    <Setter Property="IsHoldingEnabled" Value="True" />
    <Setter Property="HorizontalContentAlignment" Value="Center" />
    <Setter Property="VerticalContentAlignment" Value="Center" />
    <Setter Property="Margin" Value="0,0,4,4" />
    <Setter Property="MinWidth" Value="{ThemeResource GridViewItemMinWidth}" />
    <Setter Property="MinHeight" Value="{ThemeResource GridViewItemMinHeight}" />
    <Setter Property="AllowDrop" Value="False" />
    <Setter Property="UseSystemFocusVisuals" Value="{StaticResource UseSystemFocusVisuals}" />
    <Setter Property="FocusVisualMargin" Value="-2" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="GridViewItem">
                <ListViewItemPresenter ContentTransitions="{TemplateBinding ContentTransitions}"
                    x:Name="Root"
                    Control.IsTemplateFocusTarget="True"
                    FocusVisualMargin="{TemplateBinding FocusVisualMargin}"
                    SelectionCheckMarkVisualEnabled="{ThemeResource GridViewItemSelectionCheckMarkVisualEnabled}"
                    CheckBrush="{ThemeResource GridViewItemCheckBrush}"
                    CheckBoxBrush="{ThemeResource GridViewItemCheckBoxBrush}"
                    DragBackground="{ThemeResource GridViewItemDragBackground}"
                    DragForeground="{ThemeResource GridViewItemDragForeground}"
                    FocusBorderBrush="{ThemeResource GridViewItemFocusBorderBrush}"
                    FocusSecondaryBorderBrush="{ThemeResource GridViewItemFocusSecondaryBorderBrush}"
                    PlaceholderBackground="{ThemeResource GridViewItemPlaceholderBackground}"
                    PointerOverBackground="{ThemeResource GridViewItemBackgroundPointerOver}"
                    PointerOverForeground="{ThemeResource GridViewItemForegroundPointerOver}"
                    SelectedBackground="{ThemeResource GridViewItemBackgroundSelected}"
                    SelectedForeground="{ThemeResource GridViewItemForegroundSelected}"
                    SelectedPointerOverBackground="{ThemeResource GridViewItemBackgroundSelectedPointerOver}"
                    PressedBackground="{ThemeResource GridViewItemBackgroundPressed}"
                    SelectedPressedBackground="{ThemeResource GridViewItemBackgroundSelectedPressed}"
                    DisabledOpacity="{ThemeResource ListViewItemDisabledThemeOpacity}"
                    DragOpacity="{ThemeResource ListViewItemDragThemeOpacity}"
                    ReorderHintOffset="{ThemeResource GridViewItemReorderHintThemeOffset}"
                    HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                    VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                    ContentMargin="{TemplateBinding Padding}"
                    CheckMode="{ThemeResource GridViewItemCheckMode}"
                    RevealBackground="{ThemeResource GridViewItemRevealBackground}"
                    RevealBorderThickness="{ThemeResource GridViewItemRevealBorderThemeThickness}"
                    RevealBorderBrush="{ThemeResource GridViewItemRevealBorderBrush}">

                    <VisualStateManager.VisualStateGroups>
                        <VisualStateGroup x:Name="CommonStates">
                            <VisualState x:Name="Normal" />
                            <VisualState x:Name="Selected" />

                            <VisualState x:Name="PointerOver">
                                <VisualState.Setters>
                                    <Setter Target="Root.(RevealBrush.State)" Value="PointerOver" />
                                </VisualState.Setters>
                            </VisualState>

                            <VisualState x:Name="PointerOverSelected">
                                <VisualState.Setters>
                                    <Setter Target="Root.(RevealBrush.State)" Value="PointerOver" />
                                </VisualState.Setters>
                            </VisualState>
                            <VisualState x:Name="PointerOverPressed">
                                <VisualState.Setters>
                                    <Setter Target="Root.(RevealBrush.State)" Value="Pressed" />
                                </VisualState.Setters>
                            </VisualState>

                            <VisualState x:Name="Pressed">
                                <VisualState.Setters>
                                    <Setter Target="Root.(RevealBrush.State)" Value="Pressed" />
                                </VisualState.Setters>
                            </VisualState>

                            <VisualState x:Name="PressedSelected">
                                <VisualState.Setters>
                                    <Setter Target="Root.(RevealBrush.State)" Value="Pressed" />
                                </VisualState.Setters>
                            </VisualState>

                        </VisualStateGroup>

                        <VisualStateGroup x:Name="DisabledStates">
                            <VisualState x:Name="Enabled" />

                            <VisualState x:Name="Disabled">
                                <VisualState.Setters>
                                    <Setter Target="Root.RevealBorderThickness" Value="0" />
                                </VisualState.Setters>
                            </VisualState>

                        </VisualStateGroup>

                    </VisualStateManager.VisualStateGroups>
                </ListViewItemPresenter>

            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
<Style TargetType="GridViewItem" BasedOn="{StaticResource GridViewItemRevealStyle}" />

相关问题