having row selection adorner reactor to selection changed events rather than key|mouse up|down

This commit is contained in:
Jake Norbut committed 2019-08-15 15:48:59 -05:00
1 parent fe179d44f2
commit ec4f88c68f
2 files changed
+9 -6

No files matched your search

@@ -54,12 +54,8 @@ namespace mbts.ui.controls.adorners {
_diy_scroll = scroll_viewer;
_diy_scp = _diy_rp.descendants_of_type<ScrollContentPresenter>().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()));
}
@@ -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;