2010-04-22 68 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