WPF/Silverlight ListBox 数据横向显示的实现

<ListBox x:Name="imgList" Width="Auto" Height="Auto" Margin="0" ScrollViewer.VerticalScrollBarVisibility="Disabled" ItemsSource="{Binding}"> <ListBox.ItemsPanel> <ItemsPanelTemplate> <WrapPanel IsItemsHost="True" /> </ItemsPanelTemplate> </ListBox.ItemsPanel> <ListBox.ItemTemplate > <DataTemplate> <Image Source="{Binding ImagePath}"/> </DataTemplate> </ListBox.ItemTemplate> </ListBox>

 

关键代码:

1.ScrollViewer.VerticalScrollBarVisibility="Disabled"

2.            <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel IsItemsHost="True" />
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>

你可能感兴趣的:(image,binding,DataTemplate)