【发布时间】:2016-04-05 16:32:37
【问题描述】:
我在我的应用程序中添加了一个汉堡菜单,我正在尝试重建 Windows 10 应用程序(如地图)中使用的“原始”汉堡菜单。
我更改了汉堡菜单的 ListViewItem 样式:
<Style x:Key="NavigationMenuListViewItemStyle" TargetType="ListViewItem">
<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}"/>
<Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseHighBrush}"/>
<Setter Property="TabNavigation" Value="Local"/>
<Setter Property="IsHoldingEnabled" Value="True"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="MinWidth" Value="{ThemeResource ListViewItemMinWidth}"/>
<Setter Property="MinHeight" Value="{ThemeResource ListViewItemMinHeight}"/>
<Setter Property="Height" Value="48"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListViewItem">
<ListViewItemPresenter CheckBrush="{ThemeResource SystemControlForegroundBaseMediumHighBrush}" ContentMargin="{TemplateBinding Padding}" CheckMode="Inline" CheckBoxBrush="{ThemeResource SystemControlForegroundBaseMediumHighBrush}" DragForeground="{ThemeResource ListViewItemDragForegroundThemeBrush}" DragOpacity="{ThemeResource ListViewItemDragThemeOpacity}" DragBackground="{ThemeResource ListViewItemDragBackgroundThemeBrush}" DisabledOpacity="{ThemeResource ListViewItemDisabledThemeOpacity}" FocusBorderBrush="{ThemeResource SystemControlForegroundAltHighBrush}" FocusSecondaryBorderBrush="{ThemeResource SystemControlForegroundBaseHighBrush}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" PointerOverForeground="{ThemeResource SystemControlHighlightAltBaseHighBrush}" PressedBackground="{ThemeResource SystemControlHighlightListMediumBrush}" PlaceholderBackground="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}" PointerOverBackground="{ThemeResource SystemControlHighlightListLowBrush}" ReorderHintOffset="{ThemeResource ListViewItemReorderHintThemeOffset}" SelectedPressedBackground="{ThemeResource ApplicationAccentLowBrush}" SelectionCheckMarkVisualEnabled="True" SelectedForeground="{ThemeResource SystemControlHighlightAltBaseHighBrush}" SelectedPointerOverBackground="{ThemeResource ApplicationAccentLowBrush}" SelectedBackground="{ThemeResource ApplicationAccentLowBrush}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}">
<ListViewItemPresenter.Content>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="48" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<FontIcon Grid.Column="0" FontSize="16" Glyph="{TemplateBinding Tag}" HorizontalAlignment="Center" VerticalAlignment="Center" />
<TextBlock Grid.Column="1" Margin="12,0,0,0" Text="{TemplateBinding Content}"></TextBlock>
</Grid>
</ListViewItemPresenter.Content>
</ListViewItemPresenter>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
我的汉堡菜单:
<SplitView x:Name="spvNavigationMenu" CompactPaneLength="48" DisplayMode="CompactOverlay" OpenPaneLength="256" RequestedTheme="Dark">
<SplitView.Pane>
<StackPanel>
<ToggleButton x:Name="tobNavigationMenu" Content="APPLICATION NAME" IsChecked="{Binding IsPaneOpen, ElementName=spvNavigationMenu, Mode=TwoWay}" Style="{StaticResource NavigationMenuToggleButtonStyle}"/>
<ListView Style="{StaticResource NavigationMenuListViewStyle}" ItemContainerStyle="{StaticResource NavigationMenuListViewItemStyle}">
<ListViewItem Content="Home" Tag=""/>
<ListViewItem Content="Search" Tag=""/>
<ListViewItem Content="Friends" Tag=""/>
<ListViewItem Content="Help" Tag=""/>
</ListView>
</StackPanel>
</SplitView.Pane>
<SplitView.Content>
<Frame x:Name="fraMain">
<Frame.ContentTransitions>
<TransitionCollection>
<NavigationThemeTransition>
<NavigationThemeTransition.DefaultNavigationTransitionInfo>
<EntranceNavigationTransitionInfo/>
</NavigationThemeTransition.DefaultNavigationTransitionInfo>
</NavigationThemeTransition>
</TransitionCollection>
</Frame.ContentTransitions>
</Frame>
</SplitView.Content>
</SplitView>
它看起来像原来的汉堡菜单,但是当我按下 ListViewItem 时,会播放 PointerDownThemeAnimation。如何删除动画?
(如果有人对汉堡菜单样式感兴趣,可以问我。我可以发布其余样式)
【问题讨论】:
标签: .net wpf listview uwp listviewitem