【问题标题】:template 10: declaring a new button in hamburger navigation and navigating to its page模板 10:在汉堡导航中声明一个新按钮并导航到其页面
【发布时间】:2016-03-22 18:35:17
【问题描述】:

我是 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>

【问题讨论】:

    标签: xaml winrt-xaml win-universal-app windows-10-universal template10


    【解决方案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>
    

    祝你好运。

    【讨论】:

      【解决方案2】:

      尝试将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">
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-07-15
        • 1970-01-01
        • 1970-01-01
        • 2021-12-11
        相关资源
        最近更新 更多