创建模板时,是否有任何理由要使用后端C#初始化程序?

时间:2019-03-16 13:06:08

标签: xamarin xamarin.forms

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

update

和c#

<?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#代码吗?

1 个答案:

答案 0 :(得分:1)

编译器需要后备类(c#文件)才能工作,这时您无法避免。

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

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

最后,收益很少,还有很多工作,这是不值得的。

您可以在此处阅读Xamarin工作人员的完整说明: https://github.com/xamarin/Xamarin.Forms/issues/4327#issuecomment-436921856