Xaml 在ItemsControl上滚动

Xaml 在ItemsControl上滚动,xaml,scrollviewer,itemscontrol,windows-phone-8.1,Xaml,Scrollviewer,Itemscontrol,Windows Phone 8.1,我在数据透视项中创建了信息,但由于某些原因,这些项不会滚动,我尝试过滚动,但它会产生一种压缩效果,不会向下滚动 我尝试过用ScrollViewer包装它,也尝试过 <ItemsControl.Template> <ControlTemplate> <ScrollViewer VerticalScrollBarVisibility="Visible" VerticalScrollMode="Enabled"> &l

我在数据透视项中创建了信息,但由于某些原因,这些项不会滚动,我尝试过滚动,但它会产生一种压缩效果,不会向下滚动

我尝试过用
ScrollViewer
包装它,也尝试过

<ItemsControl.Template>
    <ControlTemplate>
        <ScrollViewer VerticalScrollBarVisibility="Visible" VerticalScrollMode="Enabled">
            <ItemsPresenter />
        </ScrollViewer>
    </ControlTemplate>
</ItemsControl.Template>

如果运气不好,有人能识别出可能的错误吗

            <PivotItem Header="unread">


                    <ItemsControl  ItemsSource="{Binding Categories}" >

                        <ItemsControl.Template>
                            <ControlTemplate>
                                <ScrollViewer VerticalScrollBarVisibility="Visible" VerticalScrollMode="Enabled" BringIntoViewOnFocusChange="True">
                                    <ItemsPresenter />
                            </ScrollViewer>
                        </ControlTemplate>
                        </ItemsControl.Template>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>

                           // ---


                            </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>

            </PivotItem>

// ---

只需将ScrollViewer放在Items控件的周围,而不是它的内部。大概是这样的:

<Pivot TabNavigation="Once">
    <PivotItem Header="unread">
        <ScrollViewer>
            <ItemsControl ItemsSource="{Binding Categories}">
                //Some ItemsControl properties and stuff
            </ItemsControl>
        </ScrollViewer>
    </PivotItem>
</Pivot>

//某些项控件属性和内容
已解决


对于阅读本文的每个人来说,问题在于枢轴位于StackPanel中。ScrollViewer不能在StackPanels内部工作,因为这些面板的高度(或宽度,取决于方向)是无限的,然后就没有任何东西可以滚动了。不过,你可以在ScrollViewer中使用StackPanel。

@Sandepbansal嗯,这对我很有用。请重试,并删除要设置为ItemsControl的ControlTemplate。在ItemsControl中只保留这一个ScrollViewer。如果这不起作用,我想我们需要更多关于ItemTemplate和其他相关信息。@Sandepbansal嗯,看起来不错,适合我。这有点牵强,但数据透视项在哪里?有堆叠面板吗?画布?它们不能很好地与ScrollViewer配合使用。不,数据透视项位于数据透视控件中。直接在仿真器上尝试并没有什么效果work@SandeepBansal好吧,你可以试着删除大ItemTemplate,只留下一个文本块,看看它是否有效,但我想问题出在ItemsControl之外。在可视化树中,页面根和轴之间的元素是什么?还有,您是否有可能通过默认样式或代码更改某些内容?愚蠢的我,原来在Pivot之前有一个StackPanel!!移除它,一切正常。谢谢你的帮助。