Scrollviewer和ItemsControl VerticalScling到nirvana

时间:2013-05-27 13:39:56

标签: silverlight windows-phone-8 itemscontrol scrollviewer

嗨我有一个复杂的ItemsControl,它用于显示带有幻灯片/淡入效果的新闻(可变高度!)。 (就像google潮流一样)我现在的问题是,滚动查看器将根据任何内容计算可用的滚动大小...如果用户滚动快速滚动会以非常难看的方式滚动!有时滚动视图会滚动到必杀技。我认为这可能是虚拟化的原因,但我无法停用它。如你所见,我已经取代了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>

0 个答案:

没有答案