UWP - 替换StackPanel以使内部内容在GridView内可伸展

时间:2016-07-13 08:07:27

标签: xaml uwp-xaml

我有问题要拉伸我的桌子(内置StackPanel的GridView),以使桌面和移动应用程序的UI响应。它看起来像StackPanel只适合其内部元素的大小。是否有一个元素可以替换我的StackPanel但是可以伸缩?

<GridView ItemsSource="{x:Bind Stuff}" IsHitTestVisible="True"
                  IsItemClickEnabled="False"
                  IsSwipeEnabled="False" Margin="0,90,0,0" x:Name="myGridView" ShowsScrollingPlaceholders="False" SelectionMode="None" IsTapEnabled="False" IsRightTapEnabled="False" IsHoldingEnabled="False" IsDoubleTapEnabled="False" ManipulationMode="None" HorizontalAlignment="Right" Width="360"><GridView.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel />
                </ItemsPanelTemplate>
            </GridView.ItemsPanel>
            <GridView.ItemTemplate>
                <DataTemplate x:DataType="data:StuffVM">
                    <Grid Tag="{Binding Url}" Tapped="Grid_Tapped">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="3*"/>
                            <ColumnDefinition Width="7*"/>
                        </Grid.ColumnDefinitions>
                        <TextBlock Padding="5,5,5,5" TextWrapping="WrapWholeWords" HorizontalAlignment="Left" Grid.Column="0" Text="{Binding Date}" FontSize="12" Foreground="#FFFFE680" Width="Auto"/>
                        <TextBlock Padding="5,5,5,5" TextWrapping="WrapWholeWords" HorizontalAlignment="Left" Grid.Column="1" Text="{Binding Text}" FontSize="12" Foreground="#FFFFE680" Width="Auto"/>
                    </Grid>
                </DataTemplate>
            </GridView.ItemTemplate>
        </GridView>

1 个答案:

答案 0 :(得分:-1)

您是否有使用StackPanel作为ItemsPanelTemplate的原因? ItemsWrapGrid或ItemsStackPanel应该伸展并使用可用区域。