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

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

问题描述

我有一个WPF的ListView其中垂直重复的数据。我无法弄清楚如何使它重复水平,就像在Windows资源管理器中的幻灯片视图。我目前的ListView定义是:

 < ListView控件的ItemsSource ={的StaticResource MyDataList}的ItemTemplate ={的StaticResource ListViewTemplate}>
< / ListView控件>
 

该DataTemplace是(虽然我认为这不应该的问题);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         

 <矩形的Horizo​​ntalAlignment =拉伸保证金=0,1,0,0X:名称=rectReflectionWIDTH =自动Grid.Row =1高度=30>
                    < Rectangle.Fill>
                        <的VisualBrush拉伸=无AlignmentX =中心AlignmentY =评出的视觉={结合的ElementName = imgPhoto}>
                            < VisualBrush.RelativeTransform>
                                <的TransformGroup>
                                    < MatrixTransform矩阵=1,0,0,-1,0,0/>
                                    &所述; TranslateTransform Y =1/>
                                < /的TransformGroup>
                            < /VisualBrush.RelativeTransform>
                        < /的VisualBrush>
                    < /Rectangle.Fill>
                    < Rectangle.OpacityMask>
                        <放射渐变画笔渐变原点=0.5,1.041>
                            < RadialGradientBrush.RelativeTransform>
                                <的TransformGroup>
                                    < ScaleTransform的centerX =0.5CenterY =0.5的ScaleX =1.202的scaleY =2.865/>
                                    &所述; SkewTransform的AngleX =0AngleY​​ =0的centerX =0.5CenterY =0.5/>
                                    &所述; RotateTransform角度=0的centerX =0.5CenterY =0.5/>
                                    < TranslateTransform X = -  0.002Y = -  0.491/>
                                < /的TransformGroup>
                            < /RadialGradientBrush.RelativeTransform>
                            &所述;渐变停止颜色=#D9000000偏移=0/>
                            <渐变停止颜色=#01FFFFFF偏移=0.8/>
                        < /&画笔GT;
                    < /Rectangle.OpacityMask>
                < /矩形>
            < /网格>
        < /边框>
    < / DataTemplate中>
 

解决方案

设置ListView控件的ItemsPanel到水平的StackPanel。像这样的:

 < ListView.ItemsPanel>
    < ItemsPanelTemplate>
        < StackPanel的方向=横向>< / StackPanel的>
    < / ItemsPanelTemplate>
< /ListView.ItemsPanel>
 

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>

The DataTemplace 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>

解决方案

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天全站免登陆