Xamarin.Forms DataBinding im code für eine Switch-Zelle

Ich habe Folgendes Objekt:

public class Notification : INotifyPropertyChanged
{
    private bool _trafficNot;
    public bool TrafficNot 
    {
        get { return _trafficNot; }
        set {
                if (value.Equals(_trafficNot))
                    return;
                _trafficNot = value;
                OnPropertyChanged();

            } 
    }

    private bool _newsNot;
    public bool NewsNot
    {
        get { return _newsNot; }
        set
        {
            if (value.Equals(_newsNot))
                return;
            _newsNot = value;
            OnPropertyChanged();
        }
    }

   public event PropertyChangedEventHandler PropertyChanged;

    void OnPropertyChanged([CallerMemberName]String propertyName=null)
    {
        var handler=PropertyChanged;
        if(handler != null)
        {
            handler(this, new PropertyChangedEventArgs(propertyName));
        }
    }

}

Bekomme ich die Daten von einem Objekt wie diesem:
//einrichten der notification-Objekt gemäß zu dem, was gespeichert ist in der DB
Notification Notification = new Notification
{

        TrafficNot = uInfo.NotificationTraffic,
        NewsNot = uInfo.NotificationNews
    };

und ich will die Daten zu binden, um diese switchells

    TableView tableView = new TableView
    {
        BindingContext = notification,
        Intent = TableIntent.Form,
        Root = new TableRoot
        {
            new TableSection
            {
                new SwitchCell
                {
                    Text = "News",
                    BindingContext = "NewsNot"

                },
                new SwitchCell
                {
                    Text = "Traffic",
                    BindingContext = "TrafficNot"
                },
                new SwitchCell
           }
        }
    };

Was ich sonst noch tun müssen, um es zu binden?

Cheers

InformationsquelleAutor user1667474 | 2014-09-23
Schreibe einen Kommentar