我在内容页面尝试了相同的布局,它有效。它不仅仅在弹出窗口中工作。
下面是我的XAML代码结构。
<toolkit:Popup
x:Class="MuniLogicMobile.View.ReportsPage"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
x:Name="popup"
Color="Transparent">
<Border
Grid.Column="1"
Stroke="{x:StaticResource Secondary}"
StrokeThickness="2">
<Border.StrokeShape>
<RoundRectangle CornerRadius="10" />
</Border.StrokeShape>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ScrollView
Margin="10"
HeightRequest="500"
VerticalOptions="FillAndExpand">
<VerticalStackLayout
Margin="10">
</VerticalStackLayout>
</ScrollView>
</Grid>
</Border>
</toolkit:Popup>
只需添加上面的布局并在弹出窗口中尝试。在 VerticalStackLayout 中添加更多项目。
我在Android平台遇到这个问题,没有在iOS中尝试过。
尝试设置滚动视图的高度,并且 将 HosrizontalOptions 和 VerticalOptions 设置为 Fill
两者单独或一起都不起作用。
我这边做了测试,但无法重现这个问题。我在 Android 模拟器(Pixel 5-Api 3)上进行了测试。
请参考我使用的以下代码,在我这边可以正常运行。
<?xml version="1.0" encoding="utf-8" ?>
<toolkit:Popup xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
x:Class="PopUpMauiApp.MyPopPage"
>
<Border
Grid.Column="1"
Stroke="#C49B33"
StrokeThickness="2">
<Border.StrokeShape>
<RoundRectangle CornerRadius="10" />
</Border.StrokeShape>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ScrollView
Margin="10"
HeightRequest="500"
VerticalOptions="FillAndExpand">
<VerticalStackLayout
Margin="10">
<Label TextColor="Red" Text="1 FOR the most wild, yet most homely narrative which I am about to pen, I neither expect nor solicit belief. Mad indeed would I be to expect it, in a case where my very senses reject their own evidence. Yet, mad am I not -- and very surely do I not dream. But to-morrow I die, and to-day I would unburthen my soul. My immediate purpose is to place before the world, plainly, succinctly, and without comment, a series of mere household events. In their consequences, these events have terrified -- have tortured -- have destroyed me. Yet I will not attempt to expound them. To me, they have presented little but Horror -- to many they will seem less terrible than barroques. Hereafter, perhaps, some intellect may be found which will reduce my phantasm to the common-place -- some intellect more calm, more logical, and far less excitable than my own, which will perceive, in the circumstances I detail with awe, nothing more than an ordinary succession of very natural causes and effects." />
<Label TextColor="Green" Text="2 FOR the most wild, yet most homely narrative which I am about to pen, I neither expect nor solicit belief. Mad indeed would I be to expect it, in a case where my very senses reject their own evidence. Yet, mad am I not -- and very surely do I not dream. But to-morrow I die, and to-day I would unburthen my soul. My immediate purpose is to place before the world, plainly, succinctly, and without comment, a series of mere household events. In their consequences, these events have terrified -- have tortured -- have destroyed me. Yet I will not attempt to expound them. To me, they have presented little but Horror -- to many they will seem less terrible than barroques. Hereafter, perhaps, some intellect may be found which will reduce my phantasm to the common-place -- some intellect more calm, more logical, and far less excitable than my own, which will perceive, in the circumstances I detail with awe, nothing more than an ordinary succession of very natural causes and effects." />
</VerticalStackLayout>
</ScrollView>
</Grid>
</Border>
</toolkit:Popup>
注:
请确保您的 nuget 使用最新版本。