繁体   English   中英

WP7中的滚动条

[英]Scroll bar in WP7

我找不到在 WP7 中滚动的方法。 我在模拟器屏幕外有更多块,但我无法滚动它。 有任何想法吗? 我是视觉新手,只是想学习,所以请解释我应该在哪里复制代码:)

    x:Class="Fitness_excercises.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
        xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d" FontFamily="{StaticResource PhoneFontFamilyNormal}"
        FontSize="{StaticResource PhoneFontSizeNormal}"
        Foreground="{StaticResource PhoneForegroundBrush}"
        SupportedOrientations="Portrait" Orientation="Portrait"
        shell:SystemTray.IsVisible="True" d:DesignHeight="768" d:DesignWidth="480">

<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent" Height="976" Width="480">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="904*" />
    </Grid.RowDefinitions>

    <!--TitlePanel contains the name of the application and page title-->
    <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
        <TextBlock x:Name="ApplicationTitle" Text="Fitness excercises" Style="{StaticResource PhoneTextNormalStyle}"/>
    </StackPanel>

    <!--ContentPanel - place additional content here-->
    <Grid x:Name="ContentPanel" Margin="12,52,12,-3" Grid.RowSpan="2">
        <Button Content="Weider's six" Height="72" HorizontalAlignment="Center" Margin="-12,52,46,0" Name="button1" VerticalAlignment="Top" Width="422" />
        <Button Content="Waist Slimming Exercises" Height="72" HorizontalAlignment="Left" Margin="-12,104,0,0" Name="button2" VerticalAlignment="Top" Width="422" />
        <Button Content="Leg excercises" Height="72" HorizontalAlignment="Left" Margin="-12,157,0,0" Name="button3" VerticalAlignment="Top" Width="422" />
        <Button Content="Buttocks excercises" Height="72" HorizontalAlignment="Left" Margin="-12,209,0,0" Name="button4" VerticalAlignment="Top" Width="422" />
        <Button Content="Hand and wrist excercises" Height="72" HorizontalAlignment="Left" Margin="-12,262,0,0" Name="button5" VerticalAlignment="Top" Width="422" />
        <Button Content="Warm-up" Height="72" HorizontalAlignment="Left" Margin="-12,0,0,0" Name="button6" VerticalAlignment="Top" Width="422" />
        <Button Content="100 push-ups" Height="72" HorizontalAlignment="Left" Margin="-13,576,0,0" Name="button7" VerticalAlignment="Top" Width="422" />
        <Button Content="300 crunches" Height="72" HorizontalAlignment="Left" Margin="-12,367,0,0" Name="button8" VerticalAlignment="Top" Width="422" />
        <Button Content="Aerobic training" Height="72" HorizontalAlignment="Left" Margin="-12,418,0,0" Name="button9" VerticalAlignment="Top" Width="422" />
        <Button Content="50 pull-ups" Height="72" HorizontalAlignment="Left" Margin="-12,469,0,0" Name="button10" VerticalAlignment="Top" Width="422" />
        <Button Content="300 squats" Height="72" HorizontalAlignment="Left" Margin="-12,524,0,0" Name="button11" VerticalAlignment="Top" Width="422" />
        <Button Content="Chest excercises" Height="72" HorizontalAlignment="Left" Margin="-12,313,0,0" Name="button13" VerticalAlignment="Top" Width="422" />
        <Button Content="Diet atlas" Height="82" HorizontalAlignment="Left" Margin="-13,629,0,0" Name="button12" VerticalAlignment="Top" Width="422" />
        <Button Content="Button" Height="82" HorizontalAlignment="Left" Margin="-13,693,0,0" Name="button14" VerticalAlignment="Top" Width="422" />
        <ScrollViewer Height="716" HorizontalAlignment="Left" Margin="456,0,0,0" Name="ScrollViewer1" VerticalAlignment="Top" Width="0" />

    </Grid>
</Grid>

<!--Sample code showing usage of ApplicationBar-->
<!--<phone:PhoneApplicationPage.ApplicationBar>
    <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
        <shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
        <shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
        <shell:ApplicationBar.MenuItems>
            <shell:ApplicationBarMenuItem Text="MenuItem 1"/>
            <shell:ApplicationBarMenuItem Text="MenuItem 2"/>
        </shell:ApplicationBar.MenuItems>
    </shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>-->

您希望滚动界面的哪一部分? 无论是哪个部分,您都应该用<ScrollViewer>包围该元素。

例如,如果您想让 ContentPanel Grid 滚动,您可以这样做:

 <ScrollViewer 
    <Grid x:Name="ContentPanel" Margin="12,52,12,-3" Grid.RowSpan="2">
    ....
    </Grid> 
 </ScrollViewer>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM