【发布时间】:2020-04-21 15:27:33
【问题描述】:
我在页面上的网格中有两行。第一个显示一些信息。在第二行中,我有另一个两行网格。第一个是 stackLayout 并显示一个圆环图,第二个是带有滚动视图和按钮的 stackLayout。单击按钮时,滚动视图会在 y 轴上平移以显示历史记录项。但是滚动视图的高度没有改变。有人知道为什么吗??
xaml 文件
<StackLayout Grid.Row="1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="200"/>
<RowDefinition Height="200"/>
</Grid.RowDefinitions>
<StackLayout Grid.Row="0">
<forms:ChartView x:Name="PieChart" HeightRequest="300"/>
</StackLayout>
<StackLayout x:Name="HistoryScroll" Grid.Row="1" TranslationY="120">
<StackLayout Padding="0" Margin="0">
<Frame x:Name="HistoryBtn" Padding="0" Margin="5, 5, 0, 5" CornerRadius="5"
HorizontalOptions="EndAndExpand" VerticalOptions="EndAndExpand"
BackgroundColor="#000058">
<Button Text="History" TextColor="#fff"
BackgroundColor="Transparent" HorizontalOptions="EndAndExpand"
VerticalOptions="EndAndExpand"
Margin="0" Padding="0" Clicked="HistoryBtnHandler"/>
</Frame>
<Frame BackgroundColor="LightGray" BorderColor="Transparent" Padding="0"
HeightRequest="10" Margin="0" HasShadow="False"/>
</StackLayout>
<ScrollView HeightRequest="300" IsEnabled="True">
<StackLayout HeightRequest="300">
<Label Text="History Item"/>
<Label Text="History Item"/>
<Label Text="History Item"/>
<Label Text="History Item"/>
<Label Text="History Item"/>
<Label Text="History Item"/>
<Label Text="History Item"/>
<Label Text="History Item"/>
<Label Text="History Item"/>
<Label Text="History Item"/>
<Label Text="History Item"/>
<Label Text="History Item"/>
<Label Text="History Item"/>
<Label Text="History Item"/>
<Label Text="History Item"/>
</StackLayout>
</ScrollView>
</StackLayout>
</Grid>
</StackLayout>
【问题讨论】:
标签: c# xamarin xamarin.forms scrollview