上次檢查代碼時,我發現我將錯誤的 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);
}
uj5u.com熱心網友回復:
實際上,如果您查看實際的DeclaringType 檔案, 它會說:
評論
沒用過
所以宣告它沒有多大意義
但是需要創建一個新的 BindableProperty,即使它毫無意義
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/345081.html
