2012-03-21 158 views
1
<ListBox Margin="0,2,0,0" SelectionChanged="OnSelectionChanged" ScrollViewer.VerticalScrollBarVisibility="Disabled" x:Name="lstUcpPanel" ItemContainerStyle="{StaticResource myContainerStyle}"> 


      <ListBox.ItemsPanel> 
       <ItemsPanelTemplate> 
        <toolkit:WrapPanel Width="Auto" Height="Auto" Margin="-7,-8,-7,0" ItemWidth="246" /> 
       </ItemsPanelTemplate> 
      </ListBox.ItemsPanel> 


      <ListBox.ItemTemplate> 
       <DataTemplate> 
        <Border BorderThickness="1" Margin="3.5,1,0,0" BorderBrush="Transparent"> 
         <StackPanel Orientation="Vertical" Background="LightGray"> 
          <Image Height="115" Width="115" Margin="2" Source="{Binding categoryImageName}" ></Image> 
          <TextBlock Text="{Binding name}" TextWrapping="Wrap" Foreground="Black" HorizontalAlignment="Center"></TextBlock> 
         </StackPanel> 

        </Border> 

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

我使用上面的代碼爲表示數據如下面的格式更改UI fdsaflksdj flhasdjhfl ASD」,然後將設計變成這樣:根據WP7文本大小

this is distorted format

我想知道有是anywa Ÿ我可以以統一的格式顯示物品,不會出現物品高度均勻的任何變形。

回答

1

設置拉伸性圖像上伸展=「填充」

<Image Height="115" Width="115" Margin="2" Source="{Binding categoryImageName}" Stretch="Fill" ></Image> 
+0

對不起,它沒有奏效。這裏的問題不在圖像中。問題在於itemheight。我想在每個項目高度 – 2012-03-21 07:12:25

1

如何讓項目在WrapPanel固定高度?

<toolkit:WrapPanel ItemHeight="80" ... /> 
+0

統一,我已經嘗試過,但這不會顯示項目中的完整文本。 – 2012-03-21 10:31:54

+0

你指定的高度是多少? – Jessica 2012-03-21 10:53:34

+0

2012-03-22 04:18:08

相關問題