java怎么写自定义布局_代码中的自定义布局

我想创建一个自定义布局,虽然我似乎无法找到正确的方法 . 自定义布局的目的是成为具有某些行为的模板 .

Under是我尝试过的(在其他一些东西中) .

代码 - 简化:

public class MyComponent : StackLayout {

public MyComponentHeader Header { get; set; }

/* Somewhat feels wrong to add this as a property */

public class MyComponentHeader : StackLayout {

}

/* Somewhat feels wrong to add this as a property */

public MyComponentBody Body { get; set; }

public class MyComponentBody : StackLayout {

}

}

用法 - 呃...:

我希望在这种情况下将“Header”和“Body”与普通StackLayout或其他布局分开的原因是因为我想要控制项目,因为它们是行为的一部分 . 我不想使用类似的东西:给我带x:Name = Header的孩子,因为这必然会失败 .

我希望这是可能的:)

谢谢!


版权声明:本文为weixin_34734156原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。