XAML で次のように定義されたリストボックスがあります。
<ListBox x:Name="directoryList"
MinHeight="100"
Grid.Row="0"
ItemsSource="{Binding Path=SelectedDirectories}"/>
SelectedDirectories は、タイプのリスト DataContext のプロパティです。List<DirectoryInfo>
リストボックスのデータ コンテキストであるクラスは、INotifyPropertyChanged を実装します。コレクションが変更されると、アイテムがリストに正常に追加されますが、リストボックスのサイズを変更して強制的に再描画するまで、表示は更新されません。
理由はありますか?
編集: INotifyPropertyChanged 実装
public class FileScannerPresenter : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private FileScanner _FileScanner;
public FileScannerPresenter()
{
this._FileScanner = new FileScanner();
}
public List<DirectoryInfo> SelectedDirectories
{
get
{
return _FileScanner.Directories;
}
}
public void AddDirectory(string path)
{
this._FileScanner.AddDirectory(path);
OnPropertyChanged("SelectedDirectories");
}
public void OnPropertyChanged(string property)
{
if (this.PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(property));
}
}
}