From f9fbebea67f3aa07e087910ab073ca3a9de64fb2 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Wed, 30 Oct 2019 10:47:22 -0500 Subject: [PATCH] clip mview animations to scroll content presenter bounds --- .../Grid/GridAnimation/DIYGridAnimationAdorner.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/client/spark/view/Spark/Utilities/Grid/GridAnimation/DIYGridAnimationAdorner.cs b/src/client/spark/view/Spark/Utilities/Grid/GridAnimation/DIYGridAnimationAdorner.cs index d59fee107..b8d15f93c 100644 --- a/src/client/spark/view/Spark/Utilities/Grid/GridAnimation/DIYGridAnimationAdorner.cs +++ b/src/client/spark/view/Spark/Utilities/Grid/GridAnimation/DIYGridAnimationAdorner.cs @@ -1,9 +1,7 @@ using bts.collections; -using bts.shell.pnl; using mbts.ui.controls; using System; using System.Collections.Generic; -using System.ComponentModel; using System.Linq; using System.Windows; using System.Windows.Controls; @@ -20,6 +18,7 @@ namespace mbts.ui.spark { IList _grid_hooks = new List(); IDictionary _column_hooks = new Dictionary(); ScrollViewer _scroll_viewer; + ScrollContentPresenter _scroll_presenter_backing; IDictionary>> _row_animation_map = new Dictionary>>(); IDictionary _column_layout = new Dictionary(); @@ -54,14 +53,20 @@ namespace mbts.ui.spark { } } + ScrollContentPresenter _scroll_presenter => + _scroll_presenter_backing ?? (_scroll_presenter_backing = _scroll_viewer?.descendants_of_type().FirstOrDefault()); + public void Dispose() { _dispose_hooks(); RemoveRowAnimationChangedHandler(_grid, _grid_RowAnimationChanged); } protected override void OnRender(DrawingContext drawingContext) { - if (_row_animation_map.Count == 0) + var sp = _scroll_presenter; + if (sp != null && _row_animation_map.Count == 0) return; + var sp_bounds = new Rect(sp.TranslatePoint(new Point(0, 0), this), sp.RenderSize); + drawingContext.PushClip(new RectangleGeometry(sp_bounds)); foreach (var row_kv in _row_animation_map) { if (_rows_presenter.ItemContainerGenerator.ContainerFromItem(row_kv.Key) is FrameworkElement row) { if (!row.IsVisible) @@ -69,6 +74,7 @@ namespace mbts.ui.spark { animate_row(drawingContext, row_kv.Key, row_kv.Value, row); } } + drawingContext.Pop(); } protected void animate_row(DrawingContext drawing_context, object row_vm, IDictionary> cell_animations, FrameworkElement row_view) {