Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.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#作为背景代码,在Xamarin表单中的框架内创建StackLayout_C#_Xamarin_Xamarin.forms_Code Behind_Children - Fatal编程技术网

使用C#作为背景代码,在Xamarin表单中的框架内创建StackLayout

使用C#作为背景代码,在Xamarin表单中的框架内创建StackLayout,c#,xamarin,xamarin.forms,code-behind,children,C#,Xamarin,Xamarin.forms,Code Behind,Children,我在我的xaml页面中使用的如下: <StackLayout> <Frame> <StackLayout> <Button></Button> <Label></Label> </StackLayout> <StackLayout> <Label>&l

我在我的
xaml
页面中使用的
如下:

<StackLayout>
    <Frame>
        <StackLayout>
            <Button></Button>
            <Label></Label>
        </StackLayout>
        <StackLayout>
            <Label></Label>
        </StackLayout>
    </Frame>
</StackLayout>

但我想在C方面做同样的事情

我定义了
堆栈布局
标签
按钮

现在我可以使用
Children
按钮添加到
StackLayout
,但是我无法将
StackLayout
添加到
框架中,因为它没有
Children
属性


是否可以使用C作为背景代码在
框架内添加
堆栈布局
。按照以下代码段在代码隐藏中创建UI:

var stackLayout=new stackLayout();
//添加内容。。。
stackLayout.Children.Add(新标签);
var帧=新帧;
frame.Content=stackLayout

此外,如果您想在框架中包含多个子元素,请将其包装在一个唯一的容器中(网格、RelativeLayout、AbsoluteLayout等)