Xamarin 创建模板时,是否有理由使用后端C#初始值设定项?

Xamarin 创建模板时,是否有理由使用后端C#初始值设定项?,xamarin,xamarin.forms,Xamarin,Xamarin.forms,我的应用程序中有以下示例: <?xml version="1.0" encoding="utf-8"?> <Grid xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:J;assembly=J"

我的应用程序中有以下示例:

<?xml version="1.0" encoding="utf-8"?>
<Grid xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
             xmlns:local="clr-namespace:J;assembly=J" 
             x:Class="J.Templates.HelpGrid" 
             Padding="15"
             RowSpacing="10"
             ColumnSpacing="10" />
从我所看到的代码工作情况来看,我可以使用该模板,而不需要或不需要对后端c#进行编码

开发人员是否有理由选择添加后端C代码?

编译器需要支持类(C文件)才能工作,此时您无法避免它

从理论上讲,可以消除支持类的需求,但这不是一件容易的事情

他们可以在编译管道中添加一个新任务,但这将大大降低构建速度(xaml越多,速度越慢)

最后,好处很少,工作也很多,这不值得

您可以在这里阅读由Xamarin员工所作的完整解释:

using System;
using System.Collections.Generic;
using Xamarin.Forms;

namespace J.Templates
{
    public partial class HelpGrid : Grid
    {
        public HelpGrid()
        {
            InitializeComponent();
        }
    }
}