【发布时间】:2019-08-02 13:00:11
【问题描述】:
我使用 .net 标准创建了一个 Xamarin 表单应用程序。然后,我在解决方案中添加了一个 .net 标准库项目,其中将包括常见代码,例如渲染、行为等。我通过右键单击依赖项和编辑引用菜单,将通用 .net 标准库项目的引用包含到主 Xamarin 表单项目中.最后,我尝试通过指定以下行在主要 Xamarin 表单的内容页面上包含渲染器文件的命名空间 使用 Xamarin.Forms;
namespace MyProject.Shared.Renderer
{
public class ExtendedEntry : Entry
{
public static readonly BindableProperty IsBorderErrorVisibleProperty = BindableProperty.Create(nameof(IsBorderErrorVisible), typeof(bool), typeof(ExtendedEntry),
false, BindingMode.TwoWay);
public bool IsBorderErrorVisible
{
get { return (bool)GetValue(IsBorderErrorVisibleProperty); }
set { SetValue(IsBorderErrorVisibleProperty, value); }
}
public static readonly BindableProperty BorderErrorColorProperty = BindableProperty.Create(nameof(BorderErrorColor), typeof(Color), typeof(ExtendedEntry),
null, BindingMode.TwoWay);
public Color BorderErrorColor
{
get { return (Color)GetValue(BorderErrorColorProperty); }
set { SetValue(BorderErrorColorProperty, value); }
}
public static readonly BindableProperty ErrorTextProperty = BindableProperty.Create(nameof(ErrorText), typeof(string), typeof(ExtendedEntry), string.Empty,
BindingMode.TwoWay);
public string ErrorText
{
get { return (string)GetValue(ErrorTextProperty); }
set { SetValue(ErrorTextProperty, value); }
}
}
}
xmlns:controls=“clr-namespace:MyProject.Shared.Renderer:assembly:MyProject.Shared”
Then I reference the control as
<controls:ExtendedEntry />
但这会产生生成错误,提示在程序集 MyProject.Shared 中找不到 ExtendedEntry
请帮忙
【问题讨论】:
标签: xamarin.forms xamarin.android xamarin.ios xamarin-studio .net-standard