C# 如何在我的内容中添加垂直滚动
有人能帮我在项目中执行垂直滚动吗?我不能这么做,有人能帮我吗?这是我的xaml代码C# 如何在我的内容中添加垂直滚动,c#,xaml,visual-studio-2012,windows-phone-8,vertical-scrolling,C#,Xaml,Visual Studio 2012,Windows Phone 8,Vertical Scrolling,有人能帮我在项目中执行垂直滚动吗?我不能这么做,有人能帮我吗?这是我的xaml代码 <Grid x:Name="LayoutRoot" Background="Black"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> <RowDefinition Height=
<Grid x:Name="LayoutRoot" Background="Black">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="Launchers" Grid.ColumnSpan="2" Margin="9,-12,-236,0" Style="{StaticResource PhoneTextTitle1Style}" Height="85" Foreground="White" FontWeight="ExtraBold" FontStretch="SemiCondensed"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"/>
<toolkit:HubTile x:Name="GuidanceButton" HorizontalAlignment="Left"
VerticalAlignment="Top" Grid.Column="0" Grid.Row="1" Background="#FF12AFC7" GroupTag="StaticHubTile" Tap="Button_gridbut_Click" Margin="30,10,0,0" Size="Medium" Source="/Images/sharemedium.png" />
<toolkit:HubTile x:Name="JourneyButton" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Column="0" Grid.Row="1" Grid.RowSpan="2" Background="#FF12AFC7" GroupTag="StaticHubTile" Height="169" Width="169" Margin="72,230,-1,0" Grid.ColumnSpan="2" Tap="Button_gridbut_Click" Source="/Images/facebook.png"/>
<toolkit:HubTile HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Column="0" Grid.Row="2" Background="#FF298391" GroupTag="StaticHubTile" Size="Small" Margin="0,99,-1,0" Height="82" Width="82"/>
<toolkit:HubTile HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Column="1" Grid.Row="1" Background="#FF298391" GroupTag="StaticHubTile" Size="Small" Margin="0,45,148,0" Height="82" Width="82"/>
<toolkit:HubTile x:Name="searchButton" HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Column="1" Grid.Row="1" Background="#FF12AFC7" GroupTag="StaticHubTile" Size="Default" Margin="0,137,61,0" Grid.RowSpan="2" Height="169" Width="169" Tap="Button_gridbut_Click" Source="/Images/camera.png" />
<toolkit:HubTile HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Column="1" Grid.Row="2" Background="#FF298391" GroupTag="StaticHubTile" Size="Small" Margin="0,7,148,0" Height="82" Width="82"/>
<toolkit:HubTile x:Name="routeButton1" HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Column="1" Grid.Row="2" Background="#FF12AFC7" GroupTag="StaticHubTile" Size="Default" Margin="0,99,61,0" Grid.RowSpan="2" Height="169" Width="169" Tap="Button_gridbut_Click" Source="/Images/status.png" />
</Grid>
</Grid>
如果您使用的是winform,您可以这样做来设置面板的垂直滚动功能:
ScrollBar vScrollBar1 = new VScrollBar();
vScrollBar1.Dock = DockStyle.Right;
vScrollBar1.Scroll += (sender, e) => { panel1.VerticalScroll.Value = vScrollBar1.Value; };
panel1.Controls.Add(vScrollBar1);
此外,您还可以阅读这篇关于在面板中添加垂直滚动条的文章:
只需将滚动内容包装在滚动控件中,如
ScrollViewer
:
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"/>
<ScrollViewer>
<toolkit:HubTile x:Name="GuidanceButton" HorizontalAlignment="Left"
VerticalAlignment="Top" Grid.Column="0" Grid.Row="1" Background="#FF12AFC7" GroupTag="StaticHubTile" Tap="Button_gridbut_Click" Margin="30,10,0,0" Size="Medium" Source="/Images/sharemedium.png" />
<toolkit:HubTile x:Name="JourneyButton" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Column="0" Grid.Row="1" Grid.RowSpan="2" Background="#FF12AFC7" GroupTag="StaticHubTile" Height="169" Width="169" Margin="72,230,-1,0" Grid.ColumnSpan="2" Tap="Button_gridbut_Click" Source="/Images/facebook.png"/>
<toolkit:HubTile HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Column="0" Grid.Row="2" Background="#FF298391" GroupTag="StaticHubTile" Size="Small" Margin="0,99,-1,0" Height="82" Width="82"/>
<toolkit:HubTile HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Column="1" Grid.Row="1" Background="#FF298391" GroupTag="StaticHubTile" Size="Small" Margin="0,45,148,0" Height="82" Width="82"/>
<toolkit:HubTile x:Name="searchButton" HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Column="1" Grid.Row="1" Background="#FF12AFC7" GroupTag="StaticHubTile" Size="Default" Margin="0,137,61,0" Grid.RowSpan="2" Height="169" Width="169" Tap="Button_gridbut_Click" Source="/Images/camera.png" />
<toolkit:HubTile HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Column="1" Grid.Row="2" Background="#FF298391" GroupTag="StaticHubTile" Size="Small" Margin="0,7,148,0" Height="82" Width="82"/>
<toolkit:HubTile x:Name="routeButton1" HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Column="1" Grid.Row="2" Background="#FF12AFC7" GroupTag="StaticHubTile" Size="Default" Margin="0,99,61,0" Grid.RowSpan="2" Height="169" Width="169" Tap="Button_gridbut_Click" Source="/Images/status.png" />
</ScrollViewer>
</Grid>
另外,删除最后一个
行定义
,因为您没有使用它,它会将您的视图一分为二。我只想为我的所有Hubbile启用垂直滚动,因为在屏幕较小的手机中。该应用程序支持不够。那么,您能告诉我我可以在代码中执行哪些更改来完成所需的工作吗?