C# 向内容页(Rg.Popups)添加不同的内容视图-Xamarin表单
我用Xamarin表单中的Rg.Popups创建了一个弹出页面。应用程序中的弹出窗口有不同的变体,理想情况下,我希望使用具有不同内容的相同弹出窗口C# 向内容页(Rg.Popups)添加不同的内容视图-Xamarin表单,c#,xaml,xamarin,xamarin.forms,C#,Xaml,Xamarin,Xamarin.forms,我用Xamarin表单中的Rg.Popups创建了一个弹出页面。应用程序中的弹出窗口有不同的变体,理想情况下,我希望使用具有不同内容的相同弹出窗口 <?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"
<?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="CustomKeyboard.Controls.CustomPopup"
xmlns:local="clr-namespace:CustomKeyboard.Controls;assembly=CustomKeyboard"
xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup">
<StackLayout
VerticalOptions="Center"
HorizontalOptions="Center"
BackgroundColor = "#00000000"
Padding="20, 0, 20, 0">
<Frame CornerRadius = "8" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand">
<local:Content1 />
</Frame>
</StackLayout>
是一个内容视图及其静态视图。我将需要内容视图是动态的
因此,当我导航到CustomPopup时,我应该能够指定需要使用哪个ContentView,并且该弹出窗口需要呈现特定的内容视图。如果有人能提出一个简洁的方法来实现这一点,我将不胜感激。我最终得到了这样一个东西,它对我来说非常有用 我只是使用c#(没有xaml)创建了这个控件。但你也可以这么做
public class PDTPopup : Rg.Plugins.Popup.Pages.PopupPage
{
public PDTPopup(ContentView view)
{
Frame frame = new Frame
{
CornerRadius = 8,
VerticalOptions = LayoutOptions.CenterAndExpand,
HorizontalOptions = LayoutOptions.CenterAndExpand,
Content = view
};
this.Content = new Xamarin.Forms.StackLayout()
{
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Center,
BackgroundColor = Color.FromHex("#00000000"),
Padding = new Thickness(20, 0, 20, 0),
Children =
{
frame
}
};
}
}
然后,我需要调用弹出窗口。我知道
public Command PopupCommand
{
get
{
return new Command(async () => {
Content1Page view = new Content1Page();
await PopupNavigation.Instance.PushAsync(new CustomPopup(view));
});
}
}