首页 > 解决方案 > 我们可以在 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 越来越拥挤。我可以有单独的文件夹用于模板吗?我怎样才能做到这一点?任何指南或教程也会有所帮助。

标签: xamlxamarinxamarin.forms

解决方案


您可以在任何 XAML 文件中定义 ResourceDictionary。请参阅此处的 Xamarin 文档:

还有一个很好的 Xamarin 大学课程:

https://university.xamarin.com/classes/track/xamarin-forms#xam140-resources-and-styles

如果您是 Xamarin 的新手,我建议您访问 Xamarin 大学。自助课程是免费的。


推荐阅读