にリストボックスをバインドしますWP7 - 私はのObservableCollectionを持っており、これはMyObjectに定義されるフィルタのObservableCollection
public class MyObject : INotifyPropertyChanged
{
private bool favourite;
public event PropertyChangedEventHandler PropertyChanged;
public bool Favourite
{
get
{
return favourite;
}
set
{
favourite = value;
var eh = PropertyChanged;
if (eh != null)
{
eh(this, new PropertyChangedEventArgs("Favourite"));
}
}
}
public bool Name { get; set; }
}
を私はWP7のリストボックスには、このコレクションをバインドしたいのですが、プロパティのお気に入りを持っている要素のみ=真。リストボックスをコレクションにどのようにバインドする必要がありますか? ObservableCollection(グローバル変数)がアプリケーションの他の部分から変更(Favorite value)を受け取ることを考慮してください。
私は(1つの要素の変更、リストボックスが更新されないのときの好きなプロパティ)成功せず、これを試してみました:
ObservableCollection<Channel> myChannels =
(((App)Application.Current).FavouriteChannels
.Where(f=>f.Favorito == true)
.OrderBy(o => o.SortIndex)
.ToList()).ToObservableCollection<Channel>();
this.listFavoritos.ItemsSource = myChannels;
任意のアイデア?