问题:我正在gridview内使用scrollview。问题是左上角的单元格从不滚动。
我尝试了其他所有单元格的许多不同组合,只有左上角不可滚动。
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:DigitalMenu"
x:Class="DigitalMenu.MainPage">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- TOP LEFT : This will NOT SCROLL :(-->
<ScrollView Grid.Row="0" Grid.Column="0">
<StackLayout>
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
</StackLayout>
</ScrollView>
<!-- TOP RIGHT This will scroll-->
<ScrollView Grid.Row="0" Grid.Column="1">
<StackLayout>
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
</StackLayout>
</ScrollView>
<!-- BOTTOM LEFT This will scroll-->
<ScrollView Grid.Row="1" Grid.Column="0">
<StackLayout>
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
</StackLayout>
</ScrollView>
<!-- BOTTOM RIGHT This will scroll-->
<ScrollView Grid.Row="1" Grid.Column="1">
<StackLayout>
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
<Button Text="Something" />
</StackLayout>
</ScrollView>
<ListView>
</ListView>
</Grid>
</ContentPage>
答案 0 :(得分:1)
您的左上方单元格无法滚动,因为您在该空间中放置了一个空列表视图。它将与原始滚动视图内容重叠,使您感觉像被卡住了。 在代码的底部,您这样写:
<Grid>
...
<ListView>
</ListView>
</Grid>
如果未显式设置其行和列,则其将为0。由于Grid的功能,Grid会将其所有子级拉伸到整个空间。稍后设置的控件将位于topper层次结构中。
最后,空白列表视图使您无法触摸滚动视图。如果删除该列表视图,则可以滚动第一个单元格。
答案 1 :(得分:0)
打开啤酒后,我有了一个绝妙的主意,那就是创建一个新的GridView并将ScrollView元素从前一个GridView移到后一个GridView,并且由于某种原因,它本身可以解决问题。我仍然不知道为什么会首先发生