Scrollviewer and ItemsControl VerticalScrolling into nirvana

别等时光非礼了梦想. 提交于 2020-01-17 08:00:11

问题


Hi i've got a complex ItemsControl wich is used to display news (variable height!) with a slide/fade in effect. (like google currents) my problem now is that the scrollviewer will calculate the available scrollingsize left based on whatever.. that will end up in a very ugly way of scrolling if the user scrolls fast! sometimes the scrollview scrolls into the nirvana. i thought this might be the cause of virtualization but i'm not able to deactivate it. as you can see i ve already replaced the ItemsPanel.

    <ScrollViewer
        ManipulationMode="Control">
        <ItemsControl
            Name="TickerItemList" 
            ItemsSource="{Binding TickerItems, Source={StaticResource TickerViewModel}}"
            HorizontalAlignment="Stretch"
            HorizontalContentAlignment="Right">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Vertical" />
                    <!--<VirtualizingStackPanel CleanUpVirtualizedItemEvent="CleanUpVirtualizedItem" VirtualizingStackPanel.VirtualizationMode="Recycling" />-->
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.Template>
                <ControlTemplate>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="1*" />
                        </Grid.RowDefinitions>
                        <Image Grid.Row="0"
                            Source="{Binding TitleImage, Source={StaticResource TickerViewModel}}" 
                            Name="TitleImage"
                            Height="240"
                            Stretch="UniformToFill"
                            Loaded="TitleImageLoaded" 
                            CacheMode="BitmapCache"/>
                        <Grid Grid.Row="1">
                            <Border Height="15" Margin="0,-15,0,0" VerticalAlignment="Top" >
                                <Border.Background>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="#00000000" Offset="0"/>
                                        <GradientStop Color="#44000000" Offset="1"/>
                                    </LinearGradientBrush>
                                </Border.Background>
                            </Border>
                            <ItemsPresenter />
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </ItemsControl.Template>
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <Grid RenderTransformOrigin="0.5,0.5" Tap="ItemTapped" Background="{StaticResource TickerPageBackgroundBrush}">
                        <!-- RenderTransform definition for animating each item -->
                        <Grid.RenderTransform>
                            <TransformGroup>
                                <ScaleTransform />
                                <TranslateTransform />
                                <RotateTransform />
                            </TransformGroup>
                        </Grid.RenderTransform>
                        <!-- Selector for ticker type -->
                        <local:NinePatch Margin="10,10,10,0" Image="{StaticResource TickerPaperImage}" CacheMode="BitmapCache">
                            <local:TickerListItemLayoutSelector Content="{Binding}">
too many lines... ;)
                            </local:TickerListItemLayoutSelector>
                        </local:NinePatch>
                    </Grid>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
    </ScrollViewer>

来源:https://stackoverflow.com/questions/16774511/scrollviewer-and-itemscontrol-verticalscrolling-into-nirvana

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!