从下ISupportIncrementalLoading顶部 [英] ISupportIncrementalLoading from bottom to top

查看:257
本文介绍了从下ISupportIncrementalLoading顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已实施 ISupportIncrementalLoading 在WinRT中的在的ListView 增量加载,它的伟大工程。
的问题是,新的项目添加到列表底部,看多的项目,我需要去了。我需要的是相反的。我想,要看到更多的项目,我需要去向上滚动。
名单基本上是一个日志文件,最新的日期必须在列表的底部显示,如果我想看较旧的记录,我需要使用滚动起来。

I have implemented ISupportIncrementalLoading in WinRT for incremental loading in a ListView, it works great. The problem is that the new items are added to bottom of list, to see more items, I need to go down. What I need is the opposite. I would like that to see more items, I would need to go scroll up. The list is basically a log file, the newest date must be displayed at bottom of the list, and if I want to see older records, I would need to use the scroll up.

有没有办法做到这一点?

Is there a way to do it?

推荐答案

我知道,问题是老了,但我有同样的问题,并没有找到一个好的解决办法。

I know, the Question is old, but I had the same problem and didn't find a good solution.

所以我会后我的其他解决办法,谁都有同样的问题。

So I will post my solution for other, who have the same problem.

我的第一个解决方案是我的自己IncrementalLoadCollection与滚动和装载数据的自定义行为。
它工作确定,但并不好enougth我。

My first solution was my own IncrementalLoadCollection with custom behaviors for scrolling and loading the data. It work OK, but not well enougth for me.

所以,我想另外一个强大的XAML招,它完美的作品,除了一个小小的鼠标滚轮行为。它现在是扭转:)。

So I tried another powerfull XAML trick and it works perfectly, except one little mouse wheel behavior. It's reversed now :).

解决方案是非常简单和强大。只需旋转180°ListView控件的ScrollViewer中和flipp其再次对右边的滚动条。然后做同样的项目,使它们是正确的一次。

Solution is very simple and powerfull. Just rotate the ScrollViewer of the ListView with 180° and flipp it to have the scrollbar on the right again. Then do the same for the Items so they are correct again.

这就是它。增量装载是由ListView的处理,触摸事件和滚动条工作正确的,现在只要鼠标滚轮行为相反。

That's it. Incremental loading is handled by ListView, touch events and scrollbar works correct, just the mouse wheel behavior is reversed now.

我的代码

<ListView Grid.Row="1" x:Name="ChatListView" ItemsSource="{TemplateBinding ItemsSource}" 
                              SelectionMode="None"
                              IsItemClickEnabled="False"
                              IsZoomedInView="False"
                            ShowsScrollingPlaceholders="False"
                            VerticalContentAlignment="Top" 
                              VerticalAlignment="Stretch" 
                              Margin="10,5">
                        <ListView.ItemContainerStyle>
                            <Style TargetType="ListViewItem">
                                <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="ListViewItem">
                                            <ContentPresenter/>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </ListView.ItemContainerStyle>
                        <ListView.ItemContainerTransitions>
                            <TransitionCollection/>
                        </ListView.ItemContainerTransitions>
                        <ListView.Template>
                            <ControlTemplate>
                                <Border BorderThickness="{TemplateBinding BorderThickness}"
                                        Padding="{TemplateBinding Padding}"
                                        BorderBrush="{TemplateBinding BorderBrush}"
                                        Background="{TemplateBinding Background}">
                                    <ScrollViewer ZoomMode="Disabled" x:Name="ScrollViewer" RenderTransformOrigin="0.5,0.5">
                                        <ScrollViewer.RenderTransform>
                                            <CompositeTransform Rotation="180" ScaleX="-1"/>
                                        </ScrollViewer.RenderTransform>
                                        <ItemsPresenter x:Name="ItemsPresenter"/>
                                    </ScrollViewer>
                                </Border>
                            </ControlTemplate>
                        </ListView.Template>
                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <controls:ChatMessageControl Message="{Binding Message}"
                                                             ChatFrom="{Binding Name}"
                                                             IsMy="{Binding IsMy}"
                                                             ShortTime="{Binding CreatedTime}"
                                                             RenderTransformOrigin="0.5,0.5">

                                    <controls:ChatMessageControl.RenderTransform>
                                        <CompositeTransform Rotation="180" ScaleX="-1"/>
                                    </controls:ChatMessageControl.RenderTransform>
                                </controls:ChatMessageControl>
                            </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>

这篇关于从下ISupportIncrementalLoading顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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