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

    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class LocationPage : ContentPage
    {
        private string Longitude { get; set; }

        public LocationPage()
        {
            InitializeComponent();
        //How to get access to Longitude here?
        }
    }
Tagged:

Best Answer

Answers

Sign In or Register to comment.