private void SetCVSSource(ListViewModel vm) { CollectionViewSource cvs = Resources["RecentItems"] as CollectionViewSource; if (cvs != null && vm != null) cvs.Source = vm.Items; }
/// <summary> /// Initializes a new instance of the <see cref="RecentListView"/> class. /// </summary> /// <param name="vm">A view model.</param> public RecentListView(ListViewModel vm) : this() { this.DataContext = vm; SetCVSSource(vm); if (vm != null) { vm.PropertyChanged += (s, e) => { if (e.PropertyName == "Items") SetCVSSource(vm); }; vm.Items.CollectionChanged += (s, e) => { RefreshCVSSource(); }; } }
/// <summary> /// Initializes a new instance of the <see cref="AllListView"/> class. /// </summary> /// <param name="vm">A view model.</param> public AllListView(ListViewModel vm) : this() { this.DataContext = vm; }