显示Windows Phone中的按钮列表可滚动

时间:2014-02-21 04:10:04

标签: c# xaml windows-phone-7 windows-phone-8

我正在制作Windows Phone应用程序,其中堆栈面板中有超过10个按钮,但它只显示屏幕中可用空间的按钮,因此如何在该页面中滚动以便所有按钮都可以访问。 这是我的代码:

<phone:PivotItem Header="second">
    <StackPanel HorizontalAlignment="Left" Height="595" Margin="10,10,0,0" VerticalAlignment="Top" Width="436">
        <Button Content="Button" />
        <Button Content="Button" >
        <Button Content="Button"/>
        <Button Content="Button"/>
        <Button Content="Button"/>
        <Button Content="Button"/>
        <Button Content="Button"/>
        <Button Content="Button"/>
        <Button Content="Button"/>
        <Button Content="Button"/>
        <Button Content="Button"/>
        <Button Content="Button"/>
    </StackPanel>

    <!--Double line list no text wrapping-->

</phone:PivotItem>

3 个答案:

答案 0 :(得分:1)

这可以启用您的布局滚动。试试这个 -

<phone:PivotItem Header="second">
    <ScrollViewer Height="500">
        <StackPanel HorizontalAlignment="Left" VerticalAlignment="Top">
            <Button Content="Button" />
            <Button Content="Button" >
            <Button Content="Button"/>
            <Button Content="Button"/>
            <Button Content="Button"/>
            <Button Content="Button"/>
            <Button Content="Button"/>
            <Button Content="Button"/>
            <Button Content="Button"/>
            <Button Content="Button"/>
            <Button Content="Button"/>
            <Button Content="Button"/>
        </StackPanel>
    </ScrollViewer>
</phone:PivotItem>

答案 1 :(得分:1)

尝试ScrollViewer课程

<ScrollViewer>
        <StackPanel HorizontalAlignment="Left"  Margin="10,10,0,0" VerticalAlignment="Top" Width="436">
            <Button Content="Button" />
            <Button Content="Button" />
                <Button Content="Button"/>
                <Button Content="Button"/>
                <Button Content="Button"/>
                <Button Content="Button"/>
                <Button Content="Button"/>
                <Button Content="Button"/>
                <Button Content="Button"/>
                <Button Content="Button"/>
                <Button Content="Button"/>
                <Button Content="Button"/>
                <Button Content="Button"/>
                <Button Content="Button"/>
                <Button Content="Button"/>
            </StackPanel>
        </ScrollViewer>

答案 2 :(得分:0)

是的,ScrollViewer控件可用于滚动比控件可用的可见区域更长的内容...

<ScrollViewer> ... content goes here ... </ScrollViewer>