【问题标题】:How to wrap a gridview around another element in xaml winrt uwp?如何在xaml winrt uwp中围绕另一个元素包装gridview?
【发布时间】:2016-03-19 06:35:41
【问题描述】:

我想实现类似于给定图中的目标。

红色部分是放置在第 0 行第 0 列的一个框架元素(StackPanel)。 橙色部分是放置在第 0 行第 1 列的 GridView。但它只环绕第 1 列。我怎样才能将它也环绕在第 0 列。

感谢您的帮助。

示例代码:

<Grid x:Name="MainGrid" Background="Brown" >
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
            <StackPanel  x:Name="RatingsBreakDownSP" Orientation="Vertical" Background="Cyan" Grid.Row="0" Grid.Column="0">
            </StackPanel>
            <GridView x:Name="reviewsBriefGV" Margin="18,10,18,18" Background="Aqua"  Grid.Row="0" Grid.Column="1" >
            </GridView>
   </Grid>

【问题讨论】:

  • 为什么不将其视为一个整体 GridView 并仅更改第一项的 itemtemplate - 这将具有合适的属性?
  • 好的,我试试看!谢谢

标签: xaml gridview windows-runtime win-universal-app


【解决方案1】:

您可以尝试以下解决方案 - 获取列表的第一个元素并将其存储在属性中 - 绑定 RatingBoard、FirstElement 和 List,使用以下相关面板跳过第一个元素

`

<RelativePanel>
        <Rectangle x:Name="RatingBoard" />
        <Rectangle x:Name="FirstElement" RelativePanel.RightOf="RatingBoard" />
        <GridView ItemsSource="{Binding}" x:Name="myList" RelativePanel.Below="FirstElement" RelativePanel.AlignLeftWithPanel="True"/>
    </RelativePanel>

`

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-16
    • 2016-08-22
    • 1970-01-01
    相关资源
    最近更新 更多