WPF: Binding Liste, ListBox

Ich habe eine Klasse:

public class A : INotifyPropertyChanged
{
    public List<B> bList { get; set; } 

    public void AddB(B b)
    {
        bList.Add(b);
        NotifyPropertyChanged("bList");
    }

    public event PropertyChangedEventHandler PropertyChanged;
    private void NotifyPropertyChanged(string info)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(info));
        }
    }
}

Sowie eine verbindliche (DataContext des UserControl ist eine Instanz von A):

<ListBox ItemsSource="{Binding Path=bList}" />

Elemente angezeigt, das Listenfeld wird nicht aktualisiert, nachdem neue Objekt in der Liste zu finden

Nach ändern der Liste, ObservableCollection und entfernen der NotifyPropertyChanged handler funktioniert alles.

Warum die Liste nicht funktioniert?

Bitte poste deinen richtigen code... Der code, den Sie geschrieben hat, kann nicht funktionieren, auch mit einer ObservableCollection. Und die NotifyPropertyChanged ändert sich nichts, da Sie Sie nicht verwenden

InformationsquelleAutor Damian | 2011-05-19

Schreibe einen Kommentar