2010-04-22 63 views

回答

6

使用ListBox。然後使用它的ItemsPanel屬性來指定方向=水平的StackPanel。

然後您可以通過使用ItemTemplate指定應該如何顯示每個產品。您沒有具體說明您要如何安排您的產品,以及您使用什麼數據結構來表示它,所以我只使用了一個可以修改的簡單模式。

代碼:

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

     <ListBox.ItemTemplate> 
      <DataTemplate> 
       <StackPanel Orientation="Horizontal"> 
        <Image Source="{TemplateBinding ImageUrl}"/> 
        <StackPanel Orientation="Vertical"> 
         <TextBlock Text="{TemplateBinding Name}"/> 
         <TextBlock Text="{TemplateBinding Price}"/> 
        </StackPanel> 
       </StackPanel> 
      </DataTemplate> 
     </ListBox.ItemTemplate> 
    </ListBox> 
+0

感謝你爲這個。這正是我所期待的。 – Scott 2011-01-07 18:50:18