I'm attempting to get MKMapKit annotations updating in real time in a Xamarin iOS project.
I'm using MvvmCross and have based the implementation on @slodge code and it's working great.
https://gist.github.com/slodge/6070386
What I'd like to be able to do now is what Stuart alludes to in one of his comments.
public class HouseAnnotation : MKAnnotation
{
public HouseAnnotation(House house)
{
// use house here...
// in theory you could also data-bind to the house too (e.g. if it's location were to move...)
}
public override CLLocationCoordinate2D Coordinate { get; set; }
}
How would I go about binding the House
coordinates to the HouseAnnotation.Coordinate
?
So far I have been doing bindings like:
var bindingSet = this.CreateBindingSet<View, ViewModel>();
which works straight forward as you do this in viewDidLoad and have access to everything you need.
I feel like I'd naturally want to do
var bindingSet = myView.CreateBindingSet<HouseAnnotation, House>();
But this means passing a reference to myView
down to the HouseAnnotation so it can be used to call CreateBindingSet
on it and I doubt this would even work because House and HouseAnnotation aren't subclasses of any Mvx base class.
I feel I'm missing a bit of the puzzle here. Is anyone able to help me out here?
I understand that houses are unlikely to move but I'm preparing for all eventualities!