2012-11-07 39 views
0

我的頁面上有以下代碼。Windows 8 XAML - GridView使用VariableSizeWrapGrid問題

<Page 
    x:Class="MyPage.MainPage" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:local="using:MyProject" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d"> 
    <ScrollViewer> 
     <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}"> 
      <Grid.RowDefinitions> 
       <RowDefinition Height="10*" /> 
       <RowDefinition Height="400*" /> 
      </Grid.RowDefinitions> 
      <TextBlock Grid.Row="0" Text="Some Header" FontSize="48" Margin="100, 50, 0, 0" /> 
      <local:CustomGridView Grid.Row="1" HorizontalAlignment="Left" Margin="100, 0, 0, 0" ItemsSource="{Binding CollectionOfYears}"> 
       <GridView.ItemsPanel> 
        <ItemsPanelTemplate> 
         <VariableSizedWrapGrid Orientation="Vertical" /> 
        </ItemsPanelTemplate> 
       </GridView.ItemsPanel> 
       <GridView.ItemTemplate> 
        <DataTemplate> 
         <Grid Height="200" Width="200"> 
          <Grid.Background> 
           <SolidColorBrush Color="{Binding Color}" /> 
          </Grid.Background> 
          <StackPanel VerticalAlignment="Bottom"> 
           <StackPanel.Background> 
            <SolidColorBrush Color="Black" Opacity="0.5" /> 
           </StackPanel.Background> 
           <TextBlock FontSize="24" Margin="10" TextAlignment="Center" Text="{Binding Year}" /> 
          </StackPanel> 
         </Grid> 
        </DataTemplate> 
       </GridView.ItemTemplate> 
      </local:CustomGridView> 
     </Grid> 
    </ScrollViewer> 
</Page> 

現在,我得到以下圖像作爲我的頁面。

https://skydrive.live.com/redir?resid=59DBB22BE5D0430E!279

如何讓gridview的填補文本塊後留出了剩餘的空間即空間被填滿?然後,如何讓變量sizewrapgrid向右流動而不是向下流動,同時仍然填充第一個以下的第二個tile等等?

編輯:我正在尋找實現該組的Windows存儲完成。一件大件物品和其他物品圍繞着它。

回答

0

好的。找出問題。

第1步:刪除滾動查看器。

第2步:將網格中第一行的高度設置爲某個固定值。

第3步:將網格中第二行的高度設置爲*。

第4步:擺脫文本塊的邊距。

第5步:在網格視圖中使用填充而不是邊距。

這將有助於解決一些問題。