void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { Action action; if (_list == null) { action = Clear; } else { action = () => { _version++; OnCollectionChanged(e); }; } CollectionSynchronizationContext sync; if (BindingBase.TryGetSynchronizedCollection(ProxiedEnumerable, out sync)) { sync.Callback(ProxiedEnumerable, sync.Context, () => { e = e.WithCount(Count); _dispatcher.DispatchIfRequired(action); }, false); } else { e = e.WithCount(Count); _dispatcher.DispatchIfRequired(action); } }
void OnPropertyChanged(object sender, PropertyChangedEventArgs e) { if (!string.IsNullOrEmpty(e.PropertyName) && string.CompareOrdinal(e.PropertyName, PropertyName) != 0) { return; } IDispatcher dispatcher = (sender as BindableObject)?.Dispatcher; dispatcher.DispatchIfRequired(() => _binding.Apply(false)); }
static void DoAction(IAnimatable self, Action action) { IDispatcher dispatcher = null; if (self is BindableObject element) { dispatcher = element.Dispatcher; } // a null dispatcher is OK as we will find one in Dispatch dispatcher.DispatchIfRequired(action); }
void InternalCollectionChanged(object sender, NotifyCollectionChangedEventArgs args) { if (args.Action == NotifyCollectionChangedAction.Reset) { var items = new List <object>(); for (int n = 0; n < _internalCollection.Count; n++) { items.Add(_internalCollection[n]); } args = new ResetNotifyCollectionChangedEventArgs(items); } _dispatcher.DispatchIfRequired(() => HandleCollectionChange(args)); }