2

I see a similar question here but following the answer there doesn't resolve this same issue. Images are still listed vertically. I am binding oData from NetFlix.

enter image description here

Following is the XAML :-

    <Window.Resources>
          <DataTemplate x:Key="ImageCell">
            <StackPanel Orientation="Horizontal">
                <Image Source="{Binding BoxArt.MediumUrl}" Width="200" Height="200" Stretch="Fill" ToolTip="{Binding Synopsis}"/>
            </StackPanel>
        </DataTemplate>
    </Window.Resources>

 <ListView Margin="21,40,26,9" Name="lvwTitles" ItemsSource="{Binding}" 
   IsSynchronizedWithCurrentItem="True" 
 SelectionMode="Single" ItemTemplate="{StaticResource ImageCell}">        
 </ListView>

Following is the code behind:-

List<Title> titles = serviceAccessor.GetAllTitlesByGenre(cmbGenre.SelectedValue.ToString());
lvwTitles.ItemsSource = titles;
Community
  • 1
  • 1
Ashish Gupta
  • 14,869
  • 20
  • 75
  • 134
  • Check this link http://stackoverflow.com/questions/1041551/wpf-listview-with-horizontal-arrangement-of-items Greetings – Iori Yagami May 05 '12 at 01:06
  • I have already seen that link and used WrapPanel and images still don't show horizontally and I believe Its certainly possible with stackpanel. – Ashish Gupta May 05 '12 at 01:09

1 Answers1

6

You are using the stackpanel in the wrong place. The stackpanel in the datatemplate just creates a stackpanel containing one single image, for each item in the listview. Try setting the itemspanel.. something like this:

<ListView>
    <ListView.ItemsPanel>
        <ItemsPanelTemplate>
            <StackPanel Orientation="Horizontal" />
        </ItemsPanelTemplate>
    </ListView.ItemsPanel>
...
</ListView>
mdm20
  • 4,475
  • 2
  • 22
  • 24