【问题标题】:Why does this ScrollViewer not produce horizontal scroll bars?为什么这个 ScrollViewer 不产生水平滚动条?
【发布时间】:2012-08-28 21:08:28
【问题描述】:

我在 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;

【问题讨论】:

    标签: xaml microsoft-metro windows-runtime


    【解决方案1】:

    【讨论】:

    • 哎哟.. 刚刚意识到我在问题措辞中忘记了一个稍微重要的否定:)问题已编辑。
    猜你喜欢
    • 2012-11-19
    • 2023-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多