Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // EventsControl class
- private bool Filter(object obj)
- {
- if (!(obj is Event @event)) return false;
- if (string.IsNullOrEmpty(Location)) return true;
- return true;
- // return @event.Location == Location;
- }
- public static readonly DependencyProperty EventsSourceProperty = DependencyProperty.Register(
- nameof(EventsSource), typeof(ObservableCollection<Event>), typeof(EventsControl), new PropertyMetadata(default(ObservableCollection<Event>), EventsSourceChanged));
- public ObservableCollection<Event> EventsSource
- {
- get => (ObservableCollection<Event>)GetValue(EventsSourceProperty);
- set => SetValue(EventsSourceProperty, value);
- }
- public ICollectionView EventsView { get; set; }
- private static void EventsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- if (!(d is EventsControl eventsControl)) return;
- var view = new CollectionViewSource { Source = e.NewValue }.View;
- view.Filter += eventsControl.Filter;
- eventsControl.EventsView = view;
- //view.Refresh();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement