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

The binding context is null until the event?

$
0
0

Hello!
Simple situation - I have a ContentPage with some data. So then I want just to write this data to the object.
But I stuck with simple problem - program is giving me a null instead of the Binding context if I will try to take it before ButtonClicked event - it will equals null.

var cItem = (Item)BindingContext;//here I'm getting null
            saveButton.Clicked += (sender, e) => 
            {
                var item = (Item)BindingContext;// and here I'm getting proper data.

Two lines of code are absolutely identical except of the fact that the second one is in event handling. How BindingContext can be null in first case when it's not null in the second one?
The fact is that when I'm going to this page, it ALREADY has a BindingContext, so how it can be null?
I'd like to get the BindingContext in the place where I'm getting null. What is my mistake?


Viewing all articles
Browse latest Browse all 91519

Trending Articles



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