Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

BindingContext always null

$
0
0

hi, I am creating portable application using SQLite, I am unable to connect BindingContext, as it is null everytime I execute the application. can anyone provide a solution for the problem, following is my code :

var nameLabel = new Label { Text = "Name" };
var nameEntry = new Entry();
nameEntry.SetBinding(Entry.TextProperty,"EmployeeName");

        var genderLabel = new Label { Text = "Gender" };
        var genderEntry = new Entry();
        genderEntry.SetBinding(Entry.TextProperty, "Gender");

        var deptLabel = new Label { Text = "Department" };
        var deptEntry = new Entry();
        deptEntry.SetBinding(Entry.TextProperty, "Department");

        var typeLabel = new Label { Text = "Employee Type" };
        var typeEntry = new Entry();
        typeEntry.SetBinding(Entry.TextProperty, "EmployeeType");

        var bdayLabel = new Label { Text = "Birth date" };
        var bdayEntry = new Entry();
        bdayEntry.SetBinding(Entry.TextProperty, "Birthdate");

        var saveButton = new Button { Text = "Save" };
        saveButton.Clicked += (sender, e) =>
        {
            var saveEmp = (DBTestWithCRUD.Model.Employee)BindingContext;
            App.Database.Save(saveEmp);
            this.Navigation.PopAsync();
        };

I am getting BindingContext null everytime when i try to save my data, although i have bound every field using SetBinding. Its working fine on the sample I have downloaded, but the same app i am trying to develop showing error and breaks the execution.
Any Idea?

Thanks


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>