2010-04-07 3 views
0

ListView를로하여 PropertyChanged 이벤트에 가입하지 :GridViewColumn이 같은, 내가에서 INotifyPropertyChanged를 구현하는 클래스의 속성에 바인딩 된의 GridView와 ListView에있는

<ListView Name="SubscriptionView" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="2" ItemsSource="{Binding Path=Subscriptions}"> 
    <ListView.View> 
     <GridView> 
      <GridViewColumn Width="24" CellTemplate="{StaticResource IncludeSubscriptionTemplate}"/> 
      <GridViewColumn Width="150" DisplayMemberBinding="{Binding Path=Name}" Header="Subscription"/> 
      <GridViewColumn Width="75" DisplayMemberBinding="{Binding Path=RecordsWritten}" Header="Records"/> 
      <GridViewColumn Width="Auto" CellTemplate="{StaticResource FilenameTemplate}"/> 
     </GridView> 
    </ListView.View> 
</ListView> 

클래스은 다음과 같습니다

public class Subscription : INotifyPropertyChanged 
{ 
    public int RecordsWritten 
    { 
     get 
     { 
      return _records; 
     } 
     set 
     { 
      _records = value; 
      if (PropertyChanged != null) 
       PropertyChanged(this, new PropertyChangedEventArgs("RecordsWritten")); 
     } 
    } 
    private int _records; 

    ... 
} 

그래서 BackgroundWorker를 실행하고 RecordsWritten 속성을 업데이트하고 UI에서 값이 변경 될 것을 기대하면서 레코드를 작성하지만 시작하지는 않습니다. 사실 Subscription 객체의 PropertyChanged 값은 null입니다. 이것은 WPF가 INotifyPropertyChanged를 구현하는 데이터 객체의 PropertyChanged 이벤트를 구독하기로되어 있기 때문에 당황합니다. 내가 여기서 뭔가 잘못하고있는거야?

답변

2

문제를 파악했습니다. "구독"목록은 LINQ 쿼리에서 왔습니다. 해당 쿼리의 끝 부분에 .ToList()를 추가하면 UI가 제대로 업데이트되기 시작했습니다.

관련 문제