![](/img/trans.png)
[英]Is there any way that I can speed up the adding of new elements to a page when using the C# back end?
[英]When creating a template is there any reason to have a back end C# initializer?
我的应用程序中有以下示例:
<?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#中
using System;
using System.Collections.Generic;
using Xamarin.Forms;
namespace J.Templates
{
public partial class HelpGrid : Grid
{
public HelpGrid()
{
InitializeComponent();
}
}
}
从我看到的代码可以正常工作,我可以使用该模板,而无需编写或不编写后端c#。
开发人员可能有任何理由选择添加后端C#代码吗?
编译器需要后备类(c#文件)才能工作,这时您无法避免。
从理论上讲,可以消除对支持类的需求,但这并不是一件容易的事。
他们可以在编译管道中添加新任务,但这会大大降低构建速度(xaml越多,速度越慢)。
最后,收益很少,还有很多工作,这是不值得的。
您可以在这里阅读Xamarin工作人员的完整说明: https : //github.com/xamarin/Xamarin.Forms/issues/4327#issuecomment-436921856
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.