我在我的应用程序中有一个例子:
<?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#代码?
发布于 2019-03-16 13:30:54
编译器需要备份类(c#文件)才能工作,此时您无法避免它。
从理论上讲,消除后台类的需求是可能的,但这不是一件容易的事情。
他们可以在编译管道中添加一个新任务,但这将大大降低构建速度(更多xaml,更慢)。
最后是很少的好处和很多的作品,它不值得。
您可以阅读Xamarin工作人员所作的全部解释,在这里:https://github.com/xamarin/Xamarin.Forms/issues/4327#issuecomment-436921856
https://stackoverflow.com/questions/55197151
复制相似问题