2010-12-15 5 views
0

사용자 지정 컨트롤에 바인딩 한 개체의 일반 목록이 있습니다. 코드 숨김에서 모든 것이 제대로 작동하는 것처럼 보이지만 컬렉션에 대한 변경 사항은 UI에 반영되지 않은 것처럼 보입니다 (비록 모든 코드를 뒤에서 찾을 수는 있지만).WPF - 바인딩 된 컬렉션에 항목 추가시 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); 
    } 
} 
여기

은 내 UI에 대한 XAML입니다

마지막으로, 바인딩 된 내 사용자 정의 컨트롤에있는 표준 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

아주 좋습니다. 감사. –

관련 문제