This repository was archived by the owner on Jun 21, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +49
-25
lines changed
GitHub.VisualStudio.UI/UI/Views Expand file tree Collapse file tree 3 files changed +49
-25
lines changed Original file line number Diff line number Diff line change 9393 <Compile Include =" Converters\CountToVisibilityConverter.cs" />
9494 <Compile Include =" Converters\DefaultValueConverter.cs" />
9595 <Compile Include =" Converters\StickieListItemConverter.cs" />
96+ <Compile Include =" Helpers\ScrollViewerUtilities.cs" />
9697 <Compile Include =" Resources.Designer.cs" >
9798 <AutoGen >True</AutoGen >
9899 <DesignTime >True</DesignTime >
Original file line number Diff line number Diff line change 1+ using System . Windows ;
2+ using System . Windows . Input ;
3+
4+ namespace GitHub . VisualStudio . UI . Helpers
5+ {
6+ /// <summary>
7+ /// Utilities for fixing WPF's broken ScrollViewer.
8+ /// </summary>
9+ public static class ScrollViewerUtilities
10+ {
11+ /// <summary>
12+ /// Fixes mouse wheel scrolling in controls that have a ScrollViewer.
13+ /// </summary>
14+ /// <param name="sender">The sender.</param>
15+ /// <param name="e">The event arguments.</param>
16+ /// <remarks>
17+ /// WPF's ScrollViewer is broken in that it doesn't pass scroll events to the parent
18+ /// control when it can't scroll any more. Add this method as an event handler to a
19+ /// control which has a ScrollViewer in its template to fix this.
20+ /// </remarks>
21+ public static void FixMouseWheelScroll ( object sender , MouseWheelEventArgs e )
22+ {
23+ try
24+ {
25+ if ( ! e . Handled )
26+ {
27+ var control = sender as FrameworkElement ;
28+ var parent = control . Parent as UIElement ;
29+
30+ if ( parent != null )
31+ {
32+ e . Handled = true ;
33+ parent . RaiseEvent ( new MouseWheelEventArgs ( e . MouseDevice , e . Timestamp , e . Delta )
34+ {
35+ RoutedEvent = UIElement . MouseWheelEvent ,
36+ Source = control ,
37+ } ) ;
38+ }
39+ }
40+ }
41+ catch
42+ {
43+ }
44+ }
45+ }
46+ }
Original file line number Diff line number Diff line change 77using GitHub . Models ;
88using System ;
99using System . Windows . Input ;
10+ using GitHub . VisualStudio . UI . Helpers ;
1011
1112namespace GitHub . VisualStudio . UI . Views
1213{
@@ -17,33 +18,9 @@ public GitHubConnectContent()
1718 InitializeComponent ( ) ;
1819
1920 DataContextChanged += ( s , e ) => ViewModel = e . NewValue as IGitHubConnectSection ;
20- repositories . PreviewMouseWheel += Repositories_PreviewMouseWheel ;
21+ repositories . PreviewMouseWheel += ScrollViewerUtilities . FixMouseWheelScroll ;
2122 }
2223
23- void Repositories_PreviewMouseWheel ( object sender , MouseWheelEventArgs e )
24- {
25- try
26- {
27- if ( ! e . Handled )
28- {
29- var uIElement = base . Parent as UIElement ;
30-
31- if ( uIElement != null )
32- {
33- e . Handled = true ;
34- uIElement . RaiseEvent ( new MouseWheelEventArgs ( e . MouseDevice , e . Timestamp , e . Delta )
35- {
36- RoutedEvent = UIElement . MouseWheelEvent ,
37- Source = this
38- } ) ;
39- }
40- }
41- }
42- catch
43- {
44- // TODO: Add trace logging: event handler called - who knows what can happen!
45- }
46- }
4724 void cloneLink_Click ( object sender , RoutedEventArgs e )
4825 {
4926 cloneLink . IsEnabled = false ;
You can’t perform that action at this time.
0 commit comments