Hi!
I have some problems with data binding, I'm pretty sure that I have done everything like in tutorial but gui still don't change values. I tried to compile on newest stable Xamarin.Forms lib and newest pre-release. Can you say me what I'm doing wrong?
This is my cell in XAML:
<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="App.SwitchCellXAML">
<StackLayout Padding="20,0,0,0" HorizontalOptions="StartAndExpand" Orientation="Horizontal">
<Image Source="Icon.png"/>
<Label Text="{Binding name}" YAlign="Center"/>
<Label Text="{Binding status}" YAlign="Center">
</Label>
</StackLayout>
</ContentView>
My class:
public class Device : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
/* There are some other lines */
public string name { get; set; }
private string _status;
public string status
{
set
{
if (_status != value)
{
_status = value;
OnPropertyChanged("status");
}
}
get
{
return _status;
}
}
protected void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this,
new PropertyChangedEventArgs(propertyName));
}
}
Creating ListView:
listView.ItemsSource = devices;
listView.ItemTemplate = new DataTemplate(typeof(SwitchCell));