0

こんにちは、myClass でこのコードを使用して、wpf アプリケーションのコンテンツを変更しています

      public event PropertyChangedEventHandler PropertyChanged;
  protected void Notify(string propertyName)
  {
     if (this.PropertyChanged != null)
     {
        PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
     }
  }

myClass のプロパティを変更するたびに、アプリにあるラベルが変更されます。

 <Label Content="{Binding Category}" Padding="7,0,0,0" />

これは問題なく動作しますが、myClass には別のクラスへの ilist を含むプロパティがあります

private IList<Article> m_articles = new List<Article>();

ここで私の質問に、Notify メソッドは Ilist のコンテンツを更新しません。ilist とビューで更新する方法があります。myclass のすべてのプロパティは、文字列または int の場合は正常に機能しますが、Ilist の場合は更新されません。私の英語が悪いという意味を理解してくれることを願っています..助けてくれてありがとう

ここにxamlのコード

                            <ListBox Name="ArtInfo" ItemsSource="{Binding Path=Articles}">
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <Label Content="{Binding Artnr}" />
                                </DataTemplate>
                            </ListBox.ItemTemplate>

{Binding Path=Articles} <-- これは ilist を含むプロパティです <-- これは Article クラスのプロパティです

4

1 に答える 1

7

List<Article> の代わりに ObservableCollection<Article> を使用する必要があります

于 2009-05-12T08:41:36.013 に答える