Hi All,
I am having some issues when creating a bindable property. I am working with the forms map control and I am wanting to bind Pins in MVVM(I may be going about this wrong but its worth a shot)
I have the following code.
Custom View
'public class CustomMapClass: Map
{
Position _pinPos;
public CustomMapClass () :base()
{
}
//Custom Property
public static readonly BindableProperty PositionProperty =
BindableProperty.Create<CustomMapClass, Position>(p => p.PinPosition, default(Position));
public Position PinPosition {
get {
return (Position)GetValue(PositionProperty);
}
set {
SetValue (PositionProperty, value);
base.Pins.Add(new Pin{Position = value}); //Setting the pin position
}
}
}
}`
ViewModel
public Position PinLocation
{
get{ return _pos; }
set
{
if (_pos != value)
{
_pos = value;
RaisePropertyChanged ("PinLocation");
}
}
}
Lastly the XAML
<views:CustomMapClass PinPosition = "{Binding PinLocation}"/>
Whenever I run the code I get the following error.
"Position 180:33. Cannot assign property "PinPosition": type mismatch between "Xamarin.Forms.Binding" and "Xamarin.Forms.Maps.Position"
Am I doing something horribly wrong? I am still sorta new to MVVM.
Thanks!