有人可以帮助我在我的项目中执行垂直滚动吗?我无法这样做,有人可以帮助我实现这一目标吗?这是我的xaml代码
<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>
答案 0 :(得分:1)
如果您使用的是winform,可以使用垂直滚动功能设置面板:
ScrollBar vScrollBar1 = new VScrollBar();
vScrollBar1.Dock = DockStyle.Right;
vScrollBar1.Scroll += (sender, e) => { panel1.VerticalScroll.Value = vScrollBar1.Value; };
panel1.Controls.Add(vScrollBar1);
此外,您可以阅读有关在面板中添加垂直滚动条的文章:
答案 1 :(得分:0)
只需在滚动控件中滚动滚动内容,例如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>
此外,删除最后一个RowDefinition
,因为您没有使用它,它会将您的视图分成两半。