如何更改GridViewItem UWP的样式?
我正在开发一个UWP应用程序,它使用图像的GridView,这些图像的行为与用户点击相关 Main.xaml如何更改GridViewItem UWP的样式?,uwp,uwp-xaml,Uwp,Uwp Xaml,我正在开发一个UWP应用程序,它使用图像的GridView,这些图像的行为与用户点击相关 Main.xaml <Page.Resources> <DataTemplate x:Key="DemoItemTemplate" x:DataType="vm:DemoImages"> <Grid> <Image Source=&
<Page.Resources>
<DataTemplate x:Key="DemoItemTemplate" x:DataType="vm:DemoImages">
<Grid>
<Image
Source="{x:Bind ImagePath}"/>
<interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="Tapped">
<core:InvokeCommandAction
Command="{x:Bind DoSomeAction}"/>
</core:EventTriggerBehavior>
</interactivity:Interaction.Behavior>
</Grid>
</DataTemplate>
</UserControl.Resources>
</Page.Resources>
<GridView
ItemsSource="{x:Bind ViewModel.ObservableCollectionOfItems}" //List of images
SelectionMode="Single"
IsItemClickEnabled="false"
ItemTemplate="{StaticResource DemoItemTemplate}"> //defining different images
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel
Orientation="Horizontal"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.ItemContainerStyle>
<Style TargetType="GridViewItemPresenter">
<Setter Property="SelectedPointerOverBackground" Value="Green"/> // tried different properties here
</Style>
</GridView.ItemContainerStyle>
</GridView>
//定义不同的图像
//在这里尝试了不同的属性
使用这段代码,当我点击我的物品时,我得到一个有上升颜色的矩形。如何修改模板以使其不包含此矩形?我试图操纵ItemContainerStyle,但没有成功
使用这段代码,当我点击我的物品时,我得到一个有上升颜色的矩形
您需要将属性设置为None
,以禁用GridView
的项目选择:
<GridView SelectionMode="None" ... />
您还可以修改GridViewItem
样式以查找BorderRectangle
,并将StrokeThickness
设置为0,以便在选择项时隐藏矩形