Xaml 如何阻止Android ScrollViewer滚动到其第一个按钮子级
我有一个非常简单的页面,有页眉、页脚和可滚动的内容。我的iOS和UWP应用程序似乎运行良好。当我进入iOS和UWP页面时,屏幕顶部会滚动滚动视图,但安卓系统似乎会向下滚动,直到你看到至少一个按钮为止 我的页面看起来像这样(页眉、大的可滚动内容和页脚): (这显然只是复制问题的样本)Xaml 如何阻止Android ScrollViewer滚动到其第一个按钮子级,xaml,uno,uno-platform,Xaml,Uno,Uno Platform,我有一个非常简单的页面,有页眉、页脚和可滚动的内容。我的iOS和UWP应用程序似乎运行良好。当我进入iOS和UWP页面时,屏幕顶部会滚动滚动视图,但安卓系统似乎会向下滚动,直到你看到至少一个按钮为止 我的页面看起来像这样(页眉、大的可滚动内容和页脚): (这显然只是复制问题的样本) 这是由于原生Android scroll viewer(隐式嵌套在XamlScrollViewer中)与按钮之间的交互,后者在接收焦点时尝试将元素滚动到视图中,而按钮在第一次加载页面时获得焦点 作为禁用此行为的解决方
这是由于原生Android scroll viewer(隐式嵌套在Xaml
ScrollViewer
中)与按钮之间的交互,后者在接收焦点时尝试将元素滚动到视图中,而按钮在第一次加载页面时获得焦点
作为禁用此行为的解决方法,您可以使用BringIntoViewOnFocusChange
属性:
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid Height="64"
Background="Blue">
<TextBlock Text="Header"
Margin="20" />
</Grid>
<ScrollViewer Grid.Row="1">
<StackPanel>
<TextBlock Text="Top"
VerticalAlignment="Top"
Height="500" />
<TextBlock Text="Content"
FontSize="66"
Margin="0,0,0,300" />
<Button Content="button"
Margin="0,0,0,300"/>
<TextBlock Text="Bottom"
VerticalAlignment="Bottom" />
</StackPanel>
</ScrollViewer>
<Grid Height="44"
Background="Green"
Grid.Row="2">
<TextBlock Text="Footer"
Margin="10" />
</Grid>
</Grid>