2012-10-15 37 views
1

我正在使用網格並在我的頁面中。頁面應該像冰塊托盤一樣分區。我怎樣才能在相等的部分分割和使用我的網格?

每個網格列包含一個圖像。

對於分割成3個等份我使用此代碼:

<ListBox SelectionChanged="listBox1_SelectionChanged" HorizontalContentAlignment="Stretch" Height="720" HorizontalAlignment="Left" Margin="1,5,0,0" Name="listBox1" VerticalAlignment="Top"> 
       <ListBox.ItemsPanel> 
        <ItemsPanelTemplate> 
         <toolkit:WrapPanel /> 
        </ItemsPanelTemplate> 
       </ListBox.ItemsPanel> 
       <ListBox.ItemTemplate> 
        <DataTemplate> 
         <Grid HorizontalAlignment="Center" VerticalAlignment="Top" Margin="3" > 
          <Grid.ColumnDefinitions> 
           <ColumnDefinition Width="1*" /> 
           <ColumnDefinition Width="1*" /> 
           <ColumnDefinition Width="1*" /> 
          </Grid.ColumnDefinitions> 

          <Border CornerRadius="6" BorderBrush="Gray" BorderThickness="2" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" x:Name="border1"> 

           <toolkit:WrapPanel x:Name="wp"> 
             <Image Source="{Binding ImagePicture}" Margin="0,10,0,0" Height="110" HorizontalAlignment="Center" VerticalAlignment="Center"/> 
             <TextBlock Margin="0,0,0,5" TextAlignment="Center" Text="{Binding categoryname}" Foreground="Black" FontStyle="Normal" Height="Auto" Width="140" HorizontalAlignment="Center" VerticalAlignment="Stretch"/> 
            </toolkit:WrapPanel> 
           </Border> 

          </Grid> 
        </DataTemplate> 
       </ListBox.ItemTemplate> 
      </ListBox> 

現在,當我利用這一點,有時圖像是小我面臨這樣的問題我已示出。

這就是我想:

This is what i want

這是我的問題:

This is my problem

能否請您分享這個問題的解決方案。

+0

http://stackoverflow.com/questions/3565066/how-to-set-grid-images-have-uniform-height-and-width試試這個 – Ayesha

+0

這個答案是針對android – arnp

回答

1

此XAML將與工作

<Grid.ColumnDefinitions> 
          <ColumnDefinition Width="1*" /> 
          <ColumnDefinition Width="1*" /> 
          <ColumnDefinition Width="1*" /> 
         </Grid.ColumnDefinitions> 
+0

我在DataTemplate中使用這個網格定義。而且我還編輯了我的問題中的代碼。 – arnp

相關問題