【问题标题】:Purpose of declaringType in BindableProperty在 BindableProperty 中声明类型的目的
【发布时间】:2021-11-02 09:31:41
【问题描述】:

上次查看我的代码时,我发现我将错误的 declaringType 分配给了我的自定义 ContentView 声明类型。这很有趣,因为它不会影响此内容视图的工作方式。它通过了 UI 测试和集成测试。所以我的问题是。在 BindableProperty 中声明类型的目的是什么?

 public partial class SomeContentView : ContentView
 {
            public static readonly BindableProperty IsSthProperty = BindableProperty.Create( 
               propertyName: nameof(IsSth),
               returnType: typeof(bool),
               declaringType: typeof(SomeContentView), <-- There were wrong assignment
               defaultValue:true);
 }

【问题讨论】:

    标签: xamarin xamarin.forms bindableproperty


    【解决方案1】:

    其实,如果你查看实际的DeclaringType documentation 它说:

    备注

    未使用

    所以声明它没有多大意义

    但是需要创建一个新的BindableProperty,即使没有意义

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多