1

我是UWP平臺的初學者,我正在使用模板10構建應用程序。我已經使用GridView作爲特定頁面,但問題是當您將鼠標懸停在其上或選擇其項目時,GridView會顯示其邊框。就像這樣:模板10:在漢堡包導航中導航並導航到其頁面的新按鈕

The Grideview Image

我希望邊框不顯示,每當用戶將鼠標懸停,或選擇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> 

回答

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"> 
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> 

好運。

+0

非常感謝!@Jerry – Uwpbeginner