【发布时间】:2022-11-18 11:57:13
【问题描述】:
我开始使用 .NET MAUI。 已安装社区工具包以显示弹出窗口。 弹出式 UI 在 iOS 中不显示透明背景颜色,而在 Android 中它工作得很好。
安卓:
iOS:
为弹出窗口添加了 XAML 文件: 弹出:
<?xml version="1.0" encoding="utf-8" ?>
<mct:Popup
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="testpopup.PopupPage"
xmlns:mct="clr-namespace:CommunityToolkit.Maui.Views;assembly=CommunityToolkit.Maui"
>
<VerticalStackLayout BackgroundColor="Transparent">
<Label
Text="Welcome to .NET MAUI!"
VerticalOptions="Center"
HorizontalOptions="Center" />
</VerticalStackLayout>
</mct:Popup>
我刚刚修改了 MainPage 上的按钮以显示弹出窗口:
private void OnCounterClicked(object sender, EventArgs e)
{
this.ShowPopup(new PopupPage());
}
任何帮助表示赞赏!
【问题讨论】:
-
您还可以将
BackgroundColor="Transparent"添加到 Popup 本身吗?在前几行,x:Class附近?如果这没有帮助(或被编译器拒绝为无效属性),那么它可能是一个错误。在github.com/CommunityToolkit/Maui/issues 添加问题。我还注意到文本没有垂直居中,这似乎是另一个错误。
标签: maui maui-community-toolkit