2013-02-01 44 views
0

我正在開發Windows Phone 8應用程序。水平綁定圖像

我想數據綁定一些圖片到列表框,但它顯示在垂直:

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> 
    <ListBox x:Name="picList"> 
     <ListBox.ItemTemplate> 
      <DataTemplate> 
       <StackPanel Orientation="Horizontal"> 
        <Image Source="{Binding picture}" Height="80" Width="80"/> 
       </StackPanel> 
      </DataTemplate> 
     </ListBox.ItemTemplate> 
    </ListBox> 
</Grid> 

回答

0

都能跟得上。您應該將ListBox的ItemsPanel設置爲具有水平方向的StackPanel。它將負責列表框中的項目排列。

<ListBox> 
    <ListBox.ItemsPanel> 
     <ItemsPanelTemplate> 
      <StackPanel Orientation="Horizontal"/> 
     </ItemsPanelTemplate> 
    </ListBox.ItemsPanel> 
</ListBox>