2012-03-21 169 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

相关问题