C#windows 8应用程序滚动视图
我似乎无法正确设置滚动视图。我可以使用scrollbar scrollview或其他任何工具,我只需要滚动功能 代码:C#windows 8应用程序滚动视图,c#,windows,scrollview,visual-studio-2013,C#,Windows,Scrollview,Visual Studio 2013,我似乎无法正确设置滚动视图。我可以使用scrollbar scrollview或其他任何工具,我只需要滚动功能 代码: 不确定我做错了什么。您只能在网格下使用: <ScrollViewer> <Grid> <Grid.RowDefinitions> <RowDefinition Height="140"/> <RowDefinition Height="65" /&g
不确定我做错了什么。您只能在网格下使用:
<ScrollViewer>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="140"/>
<RowDefinition Height="65" />
<RowDefinition Height="30" />
<RowDefinition Height="65" />
<RowDefinition Height="30" />
<RowDefinition Height="65" />
<RowDefinition Height="30" />
<RowDefinition Height="65" />
<RowDefinition Height="30" />
<RowDefinition Height="65" />
<RowDefinition Height="30" />
<RowDefinition Height="65" />
<RowDefinition Height="65" />
<RowDefinition Height="30" />
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
</Grid>
</ScrollViewer>
我想那是你的问题
简化示例:
整个页面只能使用一个滚动查看器。此滚动查看器可以有一个包含多行(或多列)的网格。然后,您可以添加任何控件并将其指定给行:
<ScrollViewer>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Text="1" Grid.Row="0" FontSize="400"/>
<TextBlock Text="2" Grid.Row="1" FontSize="400"/>
<TextBlock Text="3" Grid.Row="2" FontSize="400"/>
</Grid>
</ScrollViewer>
不移动整个页面
您可以在滚动查看器外部创建网格,如下所示:
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<ScrollViewer Grid.Row="0" VerticalAlignment="Top">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Text="1" Grid.Row="0" FontSize="400"/>
<TextBlock Text="2" Grid.Row="1" FontSize="400"/>
<TextBlock Text="3" Grid.Row="2" FontSize="400"/>
</Grid>
</ScrollViewer>
<Grid Grid.Row="1">
<TextBlock
Text="outside of ScrollView control"
Foreground="Red" FontSize="50"
VerticalAlignment="Center"
HorizontalAlignment="Center"/>
</Grid>
</Grid>
这是正确的。您可能还想禁用scrollviewer缩放功能,默认情况下,由于某些未知原因,该功能处于启用状态。但整个片段已在网格中。页面的大网格。如果我放入另一个网格,模板就会混乱。我不太确定是否可以在网格中的控件中指定行。然后我该怎么做才能具有滚动功能。如果我有很多按钮,我应该把它们放在一行吗?@user3155730,您可以将控件放在ScrollView中,并为每个控件分配一行。您是否尝试过在网格上设置
ScrollViewer.VerticalScrollBarVisibility=“Visible”
?是的,我有。。。。。。。。。。。。。。。。。。。
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<ScrollViewer Grid.Row="0" VerticalAlignment="Top">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Text="1" Grid.Row="0" FontSize="400"/>
<TextBlock Text="2" Grid.Row="1" FontSize="400"/>
<TextBlock Text="3" Grid.Row="2" FontSize="400"/>
</Grid>
</ScrollViewer>
<Grid Grid.Row="1">
<TextBlock
Text="outside of ScrollView control"
Foreground="Red" FontSize="50"
VerticalAlignment="Center"
HorizontalAlignment="Center"/>
</Grid>
</Grid>