【发布时间】:2017-03-12 06:09:02
【问题描述】:
好吧,我正在尝试制作一个类似于用户缩略图视图的自定义视图。 视图(ViewCell?)显示 UserModel(我的自定义模型)的缩略图 + 用户名。
这是UploaderCell.xaml.cs中的代码
public static readonly BindableProperty UploaderProperty =
BindableProperty.Create(
propertyName: "Uploader",
returnType: typeof(UserModel),
declaringType: typeof(UploaderCell)
);
public UserModel Uploader
{
get
{ return GetValue(UploaderProperty) as UserModel; }
set
{ SetValue(UploaderProperty, value); }
}
这就像<UploaderCell Uploader="{Binding post.uploader}"/>
在其他地方。
我得到的错误是System.InvalidCastException Class
实际上传递错误的数据不是我的错误。
所以我的问题是,是否不可能使用非基本类型(字符串、int 等)制作 BindableProperties?
【问题讨论】:
标签: xaml xamarin data-binding xamarin.forms