Forum Xamarin Xamarin.Forms

Accessing ViewModel properties from View xaml.cs class

Hello! I have a viewmodel class where there are some properties. I need to bind to this properties in code from View. How to do this?

Ex, ViewModel:

class LocationViewModel : BaseViewModel
        private readonly IDataService _dataService;

        public LocationViewModel(IDataService dataService)
                _dataService = dataService;

        public string Longitude => _dataService.GetLongtitude();

And View

    public partial class LocationPage : ContentPage
        private string Longitude { get; set; }

        public LocationPage()
        //How to get access to Longitude here?

Best Answer


Sign In or Register to comment.