Forms Interface Data Usage

Hello fellow devs, I've got a question regarding the interface and depedency service in xamarin.forms.
Let's assume the following example:
I have a simple Forms PCL project and implemented the default way of receiving gps coordinates of the device, which works fine.
In order to get those I have a method that is triggered every time the location changes, so an event.
Now I want to send that data (simple doubles) to my Forms class (MainPagefor example).
For that I have an interface with a method that receives two doubles as parameters. (void ReceiveLocation(double longitude, double latitude);)
The iOS class which has the data calls it and uses the data as input for the method.
DependencyService.Get<LocationReceiver>().ReceiveLocation(location.Coordinate.Longitude, location.Coordinate.Latitude);
The Forms class implements the interface so it can receive the data.
public void ReceiveLocation(double longitude, double latitude){ Debug.WriteLine("this! long: " + longitude + ", lat: " + latitude); //output.Text = "lat: " + latitude.ToString() + ", long: " + longitude.ToString(); received = "this! long: " + longitude + ", lat: " + latitude; }
My problem here is, why am I able to output that data from my forms class only
when I'm using the debugger? Even if I assign the data to a variable inside the Forms class
it won't change.


Sign In or Register to comment.