C# 如何在Xamarin.Form中创建自定义弹出窗口
在Xamarin.Forms中,我需要创建一个弹出窗口,在弹出窗口中显示登录页面 这是我使用xlab弹出控件的代码C# 如何在Xamarin.Form中创建自定义弹出窗口,c#,xamarin,xamarin.forms,popupwindow,xlabs,C#,Xamarin,Xamarin.forms,Popupwindow,Xlabs,在Xamarin.Forms中,我需要创建一个弹出窗口,在弹出窗口中显示登录页面 这是我使用xlab弹出控件的代码 MainPage l = new MainPage(); Navigation.PushModalAsync(l); PopupLayout popupLayout = new PopupLayout(); popupLayout.Content = l.Content; ShowPopup(l); MainPage扩展了ContentPage,目前它在登录屏幕上运行良
MainPage l = new MainPage();
Navigation.PushModalAsync(l);
PopupLayout popupLayout = new PopupLayout();
popupLayout.Content = l.Content;
ShowPopup(l);
MainPage
扩展了ContentPage
,目前它在登录屏幕上运行良好,但我的要求是将其显示为弹出窗口。有人能帮忙吗?或者还有其他方法可以做到这一点吗?以下是您的方法
private async void ShowPopup()
{
//Create `ContentPage` with padding and transparent background
ContentPage loginPage = new ContentPage
{
BackgroundColor = Color.FromHex("#D9000000"),
Padding = new Thickness(20, 20, 20, 20)
};
// Create Children
//Create desired layout to be a content of your popup page.
var contentLayout = new StackLayout
{
VerticalOptions = LayoutOptions.CenterAndExpand,
HorizontalOptions = LayoutOptions.FillAndExpand,
Orientation = StackOrientation.Vertical,
Children =
{
// Add children
}
};
//set popup page content:
loginPage.Content = contentLayout;
//Show Popup
await Navigation.PushModalAsync(loginPage, false);
}
@谢谢你的帮助 这是我最后的工作代码。但它不能被称为弹出窗口。这正好达到我的目的
private async void ShowPopup()
{
ContentPage detailsPage = new ContentPage
{
BackgroundColor = Color.Transparent,// Color.FromHex("#00F0F8FF"),
Padding = new Thickness(40, 40, 40, 40)
};
MainPage l = new MainPage();
detailsPage.Content = l.Content;
Button b = l.FindByName<Button>("btnClose");
b.Clicked += ((o2, e2) =>
{
this.Navigation.PopModalAsync();
});
await Navigation.PushModalAsync(detailsPage, false);
}
private async void ShowPopup()
{
ContentPage detailsPage=新建ContentPage
{
BackgroundColor=Color.Transparent,//Color.FromHex(“#00F0F8FF”),
填充=新厚度(40,40,40,40)
};
主页l=新主页();
detailsPage.Content=l.Content;
按钮b=l.FindByName(“btnClose”);
b、 点击+=((o2,e2)=>
{
this.Navigation.PopModalAsync();
});
等待导航。PushModalAsync(detailsPage,false);
}
Hi@Misho这里是弹出屏幕的实际屏幕截图。
在弹出内容屏幕中,单击按钮,然后单击如何关闭此弹出屏幕?返回参数并通知调用者屏幕?您可以从按钮clickHi misho的弹出页面调用
SendBackButtonPressed()
方法谢谢您的帮助,但SendBackButtonPressed()不做任何操作。这并不是真正的弹出窗口,而是打开新的页面