gpt4 book ai didi

c# - Xamarin Forms Rg.Plugins.Popup

转载 作者:太空宇宙 更新时间:2023-11-03 14:53:28 26 4
gpt4 key购买 nike

我正在尝试在 Xamarin Forms 3.0.0.530893 中创建一个弹出页面。我使用 Rg.Plugins.Popup v.1.1.4.158-pre 并在 Android 8.0.0 上进行测试。但是弹出窗口显示在左上角,无论我在水平和垂直选项中输入什么。

这是我的弹出页面

<?xml version="1.0" encoding="utf-8" ?>
<pages:PopupPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ScanApp.Page.Popup.SignOutPopup"
xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup">
<StackLayout BackgroundColor="White" HorizontalOptions="Center" VerticalOptions="Center">
<Label Text="Log ud" TextColor="Black"></Label>
<Label Text="AutomationProperties du sikker på du ønsker at logge ud?"></Label>
<Button Text="LOG UD"></Button>
<Button Text="ANNULLER"></Button>
</StackLayout>
</pages:PopupPage>

这是后端

using Rg.Plugins.Popup.Pages;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace ScanApp.Page.Popup
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class SignOutPopup : PopupPage
{
public SignOutPopup ()
{
InitializeComponent ();
}
}

这里我在MainActivity OnCreate中初始化Android插件

 Rg.Plugins.Popup.Popup.Init(this,bundle);

这里我推送页面

Navigation.PushPopupAsync(new SignOutPopup());

最佳答案

我不确定这个插件究竟是如何工作的,但我已经在过去的项目中使用过它,这里是我所做的:

我建议你这样定义你的页面。将您的堆栈布局嵌入到“全屏”框架中,并为您的框架设置一些边距和填充:

<?xml version="1.0" encoding="utf-8" ?>
<pages:PopupPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ScanApp.Page.Popup.SignOutPopup"
xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"
>

<Frame HorizontalOptions="Center" VerticalOptions="Center"
BackgroundColor="White" Margin="20" Padding="20">

<StackLayout>
<Label Text="Log ud" TextColor="Black"></Label>
<Label Text="AutomationProperties du sikker på du ønsker at logge ud?"></Label>
<Button Text="LOG UD"></Button>
<Button Text="ANNULLER"></Button>
</StackLayout>

</Frame>
</pages:PopupPage>

Xamarin Forms Frame class 具有特定属性,例如“CornerRadius”或“HasShadow”,可为您的框架提供真正的“弹出式”外观...你的框架应该居中。

告诉我它是否有效...

关于c# - Xamarin Forms Rg.Plugins.Popup,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50720640/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com