c# - 创建具有动态子级的可重用组件
问题描述
我一直在寻找解决方案,但我不太清楚要搜索什么。我基本上想创建一个具有顶部和底部工具栏的可重用组件,如下所示:
<StackLayout>
<StackLayout Orientation="Horizontal" VerticalOptions="Start" BackgroundColor="{StaticResource ToolbarColor}">
<!-- Top toolbar content-->
</StackLayout>
<!- ??? -->
<StackLayout Orientation="Horizontal" VerticalOptions="End" BackgroundColor="{StaticResource ToolbarColor}">
<!-- Bottom toolbar content -->
</StackLayout>
</StackLayout>
然后我希望能够像这样使用它:
<ToolbarComponent>
<!-- Contents -->
</ToolbarComponent>
我不知道该怎么做,是 ToolbarComponent 的标记,我在哪里放 ??? 是,以便我指定的页面内容被插入其中?
解决方案
要做的事情是为工具栏创建两个单独的用户控件。
然后像这样使用它们。
<StackLayout>
<controls:TopToolbar/>
<!-- Contents -->
<controls:BottomToolbar>
</StackLayout>
推荐阅读
- c++ - STL 中的 Sort 方法不能交换向量中的内容
- python - 在 DataFrame 之间复制现有列
- ios - 如果 iOS 应用程序转移到另一个用户帐户,那么它的 url 会改变吗?
- java - 通过 Http Params 将复杂对象列表发送到 Spring MVC Rest Controller
- javascript - 自定义折线图
- php - 尝试在 PHP 中运行程序并传递命令行参数,但参数未传递给程序
- javascript - 安装 babel 后,我得到一个未声明变量的异常
- angular - 来自 FormGroup 的禁用控件(表单自定义表单控件的一部分)被父级中的 .getRawValue() 排除
- vue.js - 如何应用这个。vuejs中promise的someFunction?
- arrays - 如果数组中没有值,如何在数组上使用 map() 编写条件渲染?