2010-12-15 17 views
0

私はカスタムコントロールにバインドしたオブジェクトの一般的なリストを持っています。コードビハインドですべてうまくいくように見えますが、コレクションに加えた変更はUIに反映されていないようです。WPF - バインドされたコレクションにアイテムが追加されたときにUIが更新されない

ここでXAMLは私のUIのためです:

<controls:ControllableListView x:Name="lvSummaryCaseEvents" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3" Label="Case Events:" ItemsSource="{Binding CaseEvents}" AddButtonClicked="ControllableListView_AddButtonClicked"> 

そして、私はコレクションに項目を追加する場所の背後にあるコード:

_caseScreen.CaseEvents.Add(caseEvent); 
//after the line above executes, lvSummaryCaseEvents (in the debugger) shows the correct number of items and the items' values are all correct. No change to the UI whatsoever 

私のユーザーコントロールのItemSourceプロパティ:

public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.Register("ItemsSource", typeof(System.Collections.IList), typeof(ControllableListView)); 

public System.Collections.IList ItemsSource 
{ 
    get 
    { 
     return this.GetValue(ItemsSourceProperty) as System.Collections.IList; 
    } 
    set 
    { 
     this.SetValue(ItemsSourceProperty, value); 
    } 
} 

最後に、バインドされた自分のユーザーコントロールに存在する標準のListViewのXAML上記のItemsSourceプロパティに:ちょうどあらためて表明し

<ListView Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="4" Name="lvListView" ItemsSource="{Binding ItemsSource}" View="{Binding View}" SelectionChanged="lvListView_SelectionChanged" /> 

私はコレクションに最初の頃を表示する場合、すべてが正常に動作しますが、私は、コレクションに項目を追加するときに、UIが変更を反映しません。事前に

おかげで、
ソニー

+0

_caseScreen.CaseEventsを何種類あるObservableCollection<T>にあなたのコレクション? –

答えて

2

変更

+0

非常に良い。ありがとう。 –

関連する問題