xaml - 我们可以在 app.xaml 以外的其他地方为 xamarin 表单控件模板定义资源吗
问题描述
我正在尝试使用基本模板构建页面。我在 app.xaml 中使用了控制模板,效果很好。
这是我所做的
<?xml version="1.0" encoding="utf-8" ?>
<Application xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="App3.App">
<Application.Resources>
<ResourceDictionary>
<ControlTemplate x:Key="baseTemplate">
但是我可以在 app.xaml 以外的任何地方定义这个控件模板资源,因为 app.xaml 越来越拥挤。我可以有单独的文件夹用于模板吗?我怎样才能做到这一点?任何指南或教程也会有所帮助。
解决方案
您可以在任何 XAML 文件中定义 ResourceDictionary。请参阅此处的 Xamarin 文档:
还有一个很好的 Xamarin 大学课程:
https://university.xamarin.com/classes/track/xamarin-forms#xam140-resources-and-styles
如果您是 Xamarin 的新手,我建议您访问 Xamarin 大学。自助课程是免费的。
推荐阅读
- java - log4j2:父记录器级别低于子记录器
- c# - 如果本地数据库已在应用程序第一次运行时播种,则拉异步不起作用
- docker - 如何在 windows server 2016 docker 容器上启用 websocket
- vue.js - 在嵌套项目列表中显示 VUE 中可拖动项目的计数
- azure-api-management - 自定义身份验证策略
- javascript - 尝试使用 D3 在地图上显示条形图,出现错误:
属性高度:属性的意外结束。预期长度,“” - angular - ag-grid cellRenderer 元素的操作不起作用
- python - 在 Python 3 中生成随机数量的特定字母
- c++ - 类替代中的命名空间别名
- node.js - 在 Centos 7 上配置运行 Nodejs 的 Nginx