代码之家  ›  专栏  ›  技术社区  ›  Tisha Anand

Xamarin forms visual studio for Mac clean命名空间问题

  •  0
  • Tisha Anand  · 技术社区  · 7 年前

    我使用.net标准创建了一个Xamarin表单应用程序。然后,我向解决方案中添加了一个.net标准库项目,该项目将包含常见代码,如呈现、行为等。我通过右键单击“依赖项和编辑引用”菜单,将公共.net标准库项目引用到主Xamarin窗体项目。最后,通过指定下面的行,我尝试在Xamarin主表单的内容页中包含呈现器文件的名称空间

    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

    请帮忙

    0 回复  |  直到 7 年前
        1
  •  0
  •   FreakyAli    7 年前

    实际上这个问题很常见,就是你的项目没有正确编译,或者编译完bin和obj之后,就没有这个类了,这很好。

    解决方案:

    • 如果即使在这之后你的问题还没有解决,那么你可能需要重新启动VS all

    如果你仍然面临这个问题,请随时回复。

        2
  •  0
  •   Tisha Anand    7 年前

    对不起…我犯了个大错…真是个大错。

    我在程序集属性中键入“:”而不是“=”。

    xmlns:controls=clr命名空间:MyProject.Shared.Renderer:assembly=MyProject.Shared

    推荐文章