如何使 WPF ListView 项目水平重复,就像水平滚动条一样? [英] How do I make WPF ListView items repeat horizontally, like a horizontal scrollbar?

查看:25
本文介绍了如何使 WPF ListView 项目水平重复,就像水平滚动条一样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 WPF ListView,它垂直重复数据.我不知道如何让它水平重复,就像 Windows 资源管理器中的幻灯片视图一样.我当前的 ListView 定义是:

I have a WPF ListView which repeats the data vertically. I cannot figure out how to make it repeat horizontally, like the slideshow view in Windows Explorer. My current ListView definition is:

<ListView ItemsSource="{StaticResource MyDataList}" ItemTemplate="{StaticResource ListViewTemplate}">
</ListView>

DataTemplate 是(尽管我认为这无关紧要);

The DataTemplate is (although I believe this should not matter);

                <Rectangle HorizontalAlignment="Stretch" Margin="0,1,0,0" x:Name="rectReflection" Width="Auto" Grid.Row="1" Height="30">
                    <Rectangle.Fill>
                        <VisualBrush Stretch="None" AlignmentX="Center" AlignmentY="Top" Visual="{Binding ElementName=imgPhoto}">
                            <VisualBrush.RelativeTransform>
                                <TransformGroup>
                                    <MatrixTransform Matrix="1,0,0,-1,0,0" />
                                    <TranslateTransform Y="1" />
                                </TransformGroup>
                            </VisualBrush.RelativeTransform>
                        </VisualBrush>
                    </Rectangle.Fill>
                    <Rectangle.OpacityMask>
                        <RadialGradientBrush GradientOrigin="0.5,1.041">
                            <RadialGradientBrush.RelativeTransform>
                                <TransformGroup>
                                    <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="1.202" ScaleY="2.865"/>
                                    <SkewTransform AngleX="0" AngleY="0" CenterX="0.5" CenterY="0.5"/>
                                    <RotateTransform Angle="0" CenterX="0.5" CenterY="0.5"/>
                                    <TranslateTransform X="-0.002" Y="-0.491"/>
                                </TransformGroup>
                            </RadialGradientBrush.RelativeTransform>
                            <GradientStop Color="#D9000000" Offset="0"/>
                            <GradientStop Color="#01FFFFFF" Offset="0.8"/>
                        </RadialGradientBrush>
                    </Rectangle.OpacityMask>
                </Rectangle>
            </Grid>
        </Border>
    </DataTemplate>

推荐答案

将 ListView 的 ItemsPanel 设置为水平 StackPanel.像这样:

Set the ItemsPanel of the ListView to a horizontal StackPanel. Like this:

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

这篇关于如何使 WPF ListView 项目水平重复,就像水平滚动条一样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆