1

我是 UWP 平台的初学者,我正在使用模板 10 构建应用程序。我已用于GridView特定页面,但问题是GridView当您将鼠标悬停在其上或选择其项目时会显示其边框。像这样:

网格视图图像

我希望边框在用户将鼠标悬停在边框上或选择一个GridView项目时不显示。

我的 XAML 代码是:

<Page
x:Class="Sample.Views.Category"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Sample.Views"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:data="using:Sample.ViewModels"
 xmlns:controls="using:Template10.Controls"
mc:Ignorable="d">
<Page.Resources>
    <DataTemplate x:DataType="data:CategoryViewModel" x:Key="CategoryDataTemplate">
        <StackPanel HorizontalAlignment="Center" Margin="10,0,20,10">

            <Image Width="150" Source="{x:Bind IconFile}" />
            <TextBlock FontSize="16" Text="{x:Bind Category}" HorizontalAlignment="Center"  />
            <!--<TextBlock FontSize="10" Text="{x:Bind Author}" HorizontalAlignment="Center" />-->
        </StackPanel>
    </DataTemplate>
</Page.Resources>
<Grid   Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <!--  header  -->
    <controls:PageHeader x:Name="pageHeader" Frame="{x:Bind Frame}" Text="Category Page" Grid.Row="0" Grid.ColumnSpan="2">
        <!--  place stretched, across top  -->
        <RelativePanel.AlignTopWithPanel>True</RelativePanel.AlignTopWithPanel>
        <RelativePanel.AlignRightWithPanel>True</RelativePanel.AlignRightWithPanel>
        <RelativePanel.AlignLeftWithPanel>True</RelativePanel.AlignLeftWithPanel>
    </controls:PageHeader>

    <GridView Grid.Row="2" >
        <GridView  ItemsSource="{x:Bind Categories}" 
              IsItemClickEnabled="True" 
              ItemClick="GridView_ItemClick"
              ItemTemplate="{StaticResource CategoryDataTemplate}" >
        </GridView>
    </GridView>
</Grid>

4

2 回答 2

1

这不是模板 10 的问题,但答案如下:

<GridView>
    <GridView.ItemContainerStyle>
        <Style TargetType="GridViewItem">
            <Setter Property="Margin" Value="0,0,4,4" />
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="TabNavigation" Value="Local"/>
            <Setter Property="IsHoldingEnabled" Value="True"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="GridViewItem">
                        <ContentPresenter />
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </GridView.ItemContainerStyle>
</GridView>

祝你好运。

于 2016-03-23T22:47:47.270 回答
0

尝试将gridview BorderThickness 设置为0,并刷到透明(假设厚度不起作用)

https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.gridview.aspx

这是 XAML 中 gridview 控件属性的链接。

既然您说您是初学者,请尝试使用不同的属性,并且由于您在 gridview 中有一个嵌套的 gridview(不知道为什么),请尝试在它们两个上设置它。

例如:

<GridView Grid.Row="2" BorderThickness="0">
于 2016-03-22T18:43:19.063 回答