【问题标题】:Windows Store App GridView Horizontal ScrollingWindows Store App GridView 水平滚动
【发布时间】:2013-11-18 12:59:04
【问题描述】:

我正在尝试使用 c# 和 xaml 为 windows 商店做新闻应用程序..

在这个项目中,我创建了一个类似于 windows phone 8 的 Panorama GridView.. 在这个 Panorama GridView 内部,我为分类创建了小的 gridviews..

Document Online的结构是这样的;

-<Grid> (whole page)
 -<Grid> (Header/Logo etc.)
 -<PanoramaGridView> (All cath will be under of this)
   -<HotNewsGridView>
     -<HotNewsGrid>
       -<GroupHeaderTextBlock>
       -<HotGridView>
   -<SportNewsGridView>
   -<PoliticsGridView>
   -<GalleryGridView>

代码的第一面..

<GridView x:Name="PanoramaGridView" 
                  Grid.Row="1" 
                  Style="{StaticResource GridViewStyle1}" 
                  ItemContainerStyle="{StaticResource GridViewItemStyle2}">
<GridViewItem Margin="0,0,2,0" VerticalAlignment="Top">
                <Grid Margin="30,0,0,0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="80"/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <GridView x:Name="HotNewsGrid" 
                              ItemsSource="{Binding}"
                              ItemTemplate="{StaticResource MansetItemTemplate}" 
                              Grid.Row="1"
                              SelectionChanged="HotNewsGrid_SelectionChanged"/>
                    <TextBlock x:Name="GroupHeaderTextBlock"
                               HorizontalAlignment="Left" 
                               Margin="0,0,-7,-18" 
                               Grid.RowSpan="1" 
                               TextWrapping="Wrap" 
                               Text="Hot News" 
                               Foreground="DarkGreen"
                               VerticalAlignment="Top" 
                               Style="{StaticResource SubheaderTextStyle}"/>
                </Grid>

问题是,当我的鼠标光标位于“HotNewsGrid”网格上时,我无法滚动。我只能从应用程序的顶部和底部滚动..

我认为,我的 PanoramaGridView 可以滚动,但是当我的光标到达 subgridviews(如热门新闻 gridview)时,它会停止滚动,无法从中滚动。我试图把 IsSwipeEnable、ScrollViewer.Horizo​​ntalScrollMode="Enabled" 等。没有工作..

我不想滚动“HotNewsGrid”。我只想在光标出现时继续滚动..

我希望你能理解我.. 这对我来说是一个非常大的问题.. 等待您的帮助..

谢谢你..

【问题讨论】:

    标签: c# xaml windows-8 windows-store-apps


    【解决方案1】:

    将此模板添加到您的 GridView

    <GridView.Template>
        <ControlTemplate>
            <ItemsPresenter />
        </ControlTemplate>
    </GridView.Template>
    

    您将能够使用鼠标滚动。

    请注意,这样做的副作用是您无法再在 GridView 上滑动选择

    【讨论】:

    • 我会把这个放在我的全景图还是每个网格视图中?
    • 我把它放在我的 GridView 中......这只会禁用滑动选择,而不是像 Windows 8.1 中那样禁用项目单击和正常选择......我使用它是因为我的 GridView 无论如何都不需要选择
    猜你喜欢
    • 1970-01-01
    • 2013-10-28
    • 1970-01-01
    • 2018-03-21
    • 2020-12-17
    • 1970-01-01
    • 2011-06-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多