使用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等)
看