英文:
How to change the black transparent backdrop of a .NET MAUI Community Toolkit Popup?
问题
当使用.ShowPopup()
方法从.NET MAUI Community Toolkit
中调用Popup
元素时,视图会显示在一个黑色透明的背景前面。如何更改该背景的颜色(最好是透明的)?
据我所知,Popup
元素本身没有允许进行此类更改的属性。我最好的猜测是,这种行为由iOS/Android平台的代码控制。如果是这样,我该如何实现这种更改?
在此先感谢您的回复。
英文:
when calling a Popup
-Element from the .NET MAUI Community Toolkit
with the .ShowPopup()
method, the View is presented in front of a black transparent backdrop. How can I change the color of said backdrop (preferable to clear transparent)?
As far as I can tell, there are no properties of the Popup-Element itself that allows me this kind of change. My best guess is, that this behavior is controlled by iOS/Android platform code. If so, how can I implement this change?
Thank you in advance for your replies.
答案1
得分: 1
I believe there should have existed a property like BackgroundColor
of Popup so it can allow us to easily change it. However, according to Properties, these properties are all related with the Popup
rather than the backdrop area that we want to customize.
作为目前的替代解决方案,您可以使用 Mopups,使您能够在您的 .NET MAUI 应用程序内创建高度可定制的弹出窗口。您可以通过 BackgroundColor
轻松更改所述背景的颜色,我将其设置为 #F4FAFC
,这是“透明清晰”的颜色。
<?xml version="1.0" encoding="utf-8" ?>
<mopups:PopupPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiAppPopups.MyPopupPage"
xmlns:mopups="clr-namespace:Mopups.Pages;assembly=Mopups"
BackgroundColor="#F4FAFC"
CloseWhenBackgroundIsClicked="True"
Title="MyPopupPage">
<VerticalStackLayout WidthRequest="250" HeightRequest="500" VerticalOptions="CenterAndExpand" BackgroundColor="Yellow">
<Label
Text="Welcome to .NET MAUI!"
VerticalOptions="Center"
HorizontalOptions="Center" />
</VerticalStackLayout>
</mopups:PopupPage>
有关更多详细信息,您可以参考 Popups For MAUI。
英文:
I believe there should have existed a property like BackgroundColor
of Popup so it can allow us to easily change it. However, according to Properties, these properties are all related with the Popup
rather than the backdrop area that we want to customize.
As an alternative workaround for now, you can use Mopups enabling you to create highly customizable popups inside of your .NET MAUI apps. You can easily change the color of said backdrop via BackgroundColor
, I set it to #F4FAFC
which is clear transparent
.
<?xml version="1.0" encoding="utf-8" ?>
<mopups:PopupPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiAppPopups.MyPopupPage"
xmlns:mopups="clr-namespace:Mopups.Pages;assembly=Mopups"
BackgroundColor="#F4FAFC"
CloseWhenBackgroundIsClicked="True"
Title="MyPopupPage">
<VerticalStackLayout WidthRequest="250" HeightRequest="500" VerticalOptions="CenterAndExpand" BackgroundColor="Yellow">
<Label
Text="Welcome to .NET MAUI!"
VerticalOptions="Center"
HorizontalOptions="Center" />
</VerticalStackLayout>
</mopups:PopupPage>
For more details, you can refer to Popups For MAUI.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论