我在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;
答案 0 :(得分:4)