Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 向内容页(Rg.Popups)添加不同的内容视图-Xamarin表单_C#_Xaml_Xamarin_Xamarin.forms - Fatal编程技术网

C# 向内容页(Rg.Popups)添加不同的内容视图-Xamarin表单

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"

我用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" 
    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));
            });
        }
    }