如何停用 GridViewItem點擊動畫(如下圖所示),右擊一個GridViewItem?如何取消激活GridViewItem單擊動畫?
編輯:
代碼後,內特的建議(不工作)。我添加了VisualStates,但我仍然看到動畫。但是,選中的項目不再具有藍色邊框,因爲我添加了VisualStateGroup
元素(我不在乎,但代碼有一些效果)。
<Page
x:Name="pageRoot"
x:Class="MovieLibrary.VideoPage"
DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MovieLibrary"
xmlns:common="using:MovieLibrary.Common"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" Loaded="pageRoot_Loaded">
<Page.Resources>
<local:SetPercentageConverter x:Key="SetPercentageConverter"/>
<!-- TODO: Delete this line if the key AppName is declared in App.xaml -->
<x:String x:Key="AppName">Hello, video!</x:String>
<Style x:Key="GridViewItemStyle" TargetType="GridViewItem">
<Setter Property="Margin" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="GridViewItem">
<GridViewItemPresenter x:Name="gridViewItemPresenter" Padding="0" ContentMargin="0">
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Pressed"><Storyboard/></VisualState>
<VisualState x:Name="PointerOverPressed"><Storyboard/></VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</GridViewItemPresenter>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Page.Resources>
<Page.TopAppBar>
<CommandBar x:Name="commandBar">
<AppBarButton x:Name="SyncMovieLibraryButton" Icon="SyncFolder" Label="Sync Movie Library" Click="SyncMovieLibraryButton_Click"/>
<AppBarButton x:Name="SetMovieLibraryButton" Icon="Folder" Label="Set Movie Library" Click="SetMovieLibraryButton_Click"/>
</CommandBar>
</Page.TopAppBar>
<GridView x:Name="videoGridView" ItemsSource="{Binding Movies}" ItemContainerStyle="{StaticResource GridViewItemStyle}" Padding="0" RightTapped="videoGridView_RightTapped">
<GridView.ItemTemplate>
<DataTemplate>
<Image Source="{Binding PosterPath}" Loaded="Image_Loaded" Stretch="UniformToFill" RightTapped="Image_RightTapped" />
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
</Page>
在[GridViewItem默認樣式和模板](http://msdn.microsoft.com/en-us/library/windows/apps/xaml/jj709915.aspx)中,特別是最下面的那個,您會注意到是'Pressed'狀態的'StoryBoard',其中包含'PointerDownThemeAnimation'。複製樣式,刪除'StoryBoard'(或者只是動畫),應該很好。 –
感謝您的回答,但是:不,不起作用。你能檢查我是否犯了一個錯誤嗎? – Daniel
它看起來像'PointerOverPressed'可能有類似的動畫。嘗試覆蓋這一點。 –