Reputation: 1284
well, i'm trying to make a custom view which is like user thumbnail view. the view(ViewCell?) displays UserModel(my custom model)'s thumbnail + username.
this is the code in 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); }
}
and this is used like <UploaderCell Uploader="{Binding post.uploader}"/>
in some where else.
and the error i get is System.InvalidCastException Class
it's not my mistake about actually passing the wrong data.
so my question is, is it impossible to make BindableProperties with non basic types(string, int ,ect..)?
Upvotes: 0
Views: 140
Reputation: 2159
Yes, it is possible to use complex types and is something I do all the time. What you have posted of your code looks correct.
I would check the code in your view model to see what you are actually binding to that value as that might be the cause of your error. If you are binding the wrong type then that might lead to the error.
Upvotes: 1