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

NullReferenceException when Binding to an Entry control on Android

$
0
0

Greets,

I've created a ViewModel and implemented the INotifyPropertyChanged interface. I only have one property, a string called "Name". I have the following code in the constructor of my ContentPage class:

XamlViewModel viewModel = new XamlViewModel(); this.BindingContext = viewModel; InitializeComponent(); viewModel.Name = "Hello World!";

The 'Name' property calls my OnPropertyChanged() method which in turn calls the PropertyChanged event on the interface. Inside the ContentPage element in the XAML, I have the following single line:

<Entry Text="{Binding Name, Mode=TwoWay}" />

When changing the name property as I did above, the call to PropertyChanged throws a NullReferenceException. I've verified that the ViewModel, property name and event are all non-null, so it appears to be something internal to the binding when the notification is raised.

Is there something that I am doing incorrectly?

Regards,

Joe


Viewing all articles
Browse latest Browse all 77050

Trending Articles



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