private void OnViewPortPropertyChanged(object sender, PropertyChangedEventArgs e) { var propertyChangesThatRequireRedraw = new[] { nameof(Core.ViewModels.ViewPort.SelectionStart), nameof(Core.ViewModels.ViewPort.SelectionEnd), nameof(Core.ViewModels.ViewPort.ScrollValue), }; if (propertyChangesThatRequireRedraw.Contains(e.PropertyName)) { InvalidateVisual(); CursorNeedsUpdate?.Invoke(this, EventArgs.Empty); } var propertyChangesThatRequireResize = new[] { nameof(IViewPort.StretchData), nameof(IViewPort.AllowMultipleElementsPerLine), nameof(Core.ViewModels.ViewPort.PreferredWidth), }; if (propertyChangesThatRequireResize.Contains(e.PropertyName)) { UpdateViewPortSize(); InvalidateVisual(); CursorNeedsUpdate?.Invoke(this, EventArgs.Empty); } }
private void OnViewPortChanged(DependencyPropertyChangedEventArgs e) { if (e.OldValue is IViewPort oldViewPort) { oldViewPort.CollectionChanged -= OnViewPortContentChanged; oldViewPort.PropertyChanged -= OnViewPortPropertyChanged; oldViewPort.RequestMenuClose -= OnViewPortRequestMenuClose; oldViewPort.Headers.CollectionChanged -= OnViewPortContentChanged; } if (e.NewValue is IViewPort newViewPort) { newViewPort.CollectionChanged += OnViewPortContentChanged; newViewPort.PropertyChanged += OnViewPortPropertyChanged; newViewPort.RequestMenuClose += OnViewPortRequestMenuClose; newViewPort.Headers.CollectionChanged += OnViewPortContentChanged; UpdateViewPortSize(); } InvalidateVisual(); CursorNeedsUpdate?.Invoke(this, EventArgs.Empty); }
private void OnViewPortContentChanged(object sender, NotifyCollectionChangedEventArgs e) { InvalidateVisual(); CursorNeedsUpdate?.Invoke(this, EventArgs.Empty); }