diff --git a/src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs b/src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs index 7e59c46e0..688be814d 100644 --- a/src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs +++ b/src/client/spark/view/Controls/Adorners/RowSelectionAdorner.cs @@ -54,12 +54,8 @@ namespace mbts.ui.controls.adorners { _diy_scroll = scroll_viewer; _diy_scp = _diy_rp.descendants_of_type().empty_if_null().FirstOrDefault(); - // so that we clear out any previously selected highlighted rows - _disposables.Add(_diy_rp.SubscribePreviewMouseDown((s, e) => InvalidateVisual())); - // the main event - _disposables.Add(_diy_rp.SubscribePreviewMouseUp((s, e) => InvalidateVisual())); - // so that we update for potential mass keyboard combinations (CTRL-A) - _disposables.Add(_diy_rp.SubscribePreviewKeyUp((s, e) => InvalidateVisual())); + // We actually don't need mouse up/down or key up/down when we can just respond to selection changes + _disposables.Add(((System.Windows.Controls.Primitives.Selector)_diy_rp).SubscribeSelectionChanged((s, e) => InvalidateVisual())); // so that we update the highlight as the grid scrolls _disposables.Add(_diy_scroll.SubscribeScrollChanged((s, e) => InvalidateVisual())); } diff --git a/src/client/spark/view/Extensions/UIElementExtensions.cs b/src/client/spark/view/Extensions/UIElementExtensions.cs index cc3e67da3..4a1096d23 100644 --- a/src/client/spark/view/Extensions/UIElementExtensions.cs +++ b/src/client/spark/view/Extensions/UIElementExtensions.cs @@ -210,6 +210,13 @@ namespace mbts.ui.extensions { } } + public static class SelectorExtensions { + public static IDisposable SubscribeSelectionChanged(this System.Windows.Controls.Primitives.Selector target, SelectionChangedEventHandler callback) { + target.SelectionChanged += callback; + return Disposable.Create(() => target.SelectionChanged -= callback); + } + } + public static class ScrollViewerExtensions { public static IDisposable SubscribeScrollChanged(this ScrollViewer target, ScrollChangedEventHandler callback) { target.ScrollChanged += callback;