0

我在 WinRT / Metro 中创建了以下页面,并希望从 ScrollViewer 获得水平和垂直滚动条,因为内容区域在两个维度上都大于屏幕和 ScrollViewer。任何人都可以在这里发现任何错误吗?

<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Test"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"  
x:Class="ScrollViewerTestPage"
mc:Ignorable="d">     

<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
    <ScrollViewer>
        <ItemsControl ItemsSource="{Binding}" Width="2500" >
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal"/>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <TextBox Width="100" Margin="5" Height="1200" Text="{Binding}"/>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
    </ScrollViewer>     
</Grid>
</Page>

数据在构造函数中初始化,如下所示:

var model = new List<string>();
for (int i = 1; i <= 20; i++) model.Add("" + i);
DataContext = model;
4

1 回答 1

4

水平滚动条有一个 scrollview 属性:http: //msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.scrollviewer.horizo ​​ntalscrollbarvisibility

于 2012-08-29T04:36:07.503 回答