2012-04-05 67 views
0

我找不到在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>--> 

回答

1

是你想要的接口的部分有滚动?无论哪个部分,都应该用<ScrollViewer>来包围该元素。

例如,如果你想拥有的ContentPanel电网滚动,你会做这样的事情:

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

好了,但是当我松开鼠标按钮谈到恢复正常。我有按钮离开屏幕,当我想点击它时,我不能,因为它回来 – 2012-04-05 21:02:34

+0

你可能会改说吗?我不太清楚你有什么问题,或者你的意思是“我的按钮远离屏幕” – oltman 2012-04-05 21:06:35

+0

在视觉上,我在我的手机屏幕上看到16个按钮,接下来的3个是远离屏幕(在这16个下方,但不可见),我必须向上移动内容面板才能看到它们。在模拟器中,当我向下滚动时(按住鼠标按钮),我会看到接下来的3个按钮,但是当我释放时,它会回到这些主要的16位。是否可以锁定视图?我的意思是,当我滚动它保持在我滚动的位置。 – 2012-04-05 21:15:59