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 93
93
<Compile Include =" Converters\CountToVisibilityConverter.cs" />
94
94
<Compile Include =" Converters\DefaultValueConverter.cs" />
95
95
<Compile Include =" Converters\StickieListItemConverter.cs" />
96
+ <Compile Include =" Helpers\ScrollViewerUtilities.cs" />
96
97
<Compile Include =" Resources.Designer.cs" >
97
98
<AutoGen >True</AutoGen >
98
99
<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 7
7
using GitHub . Models ;
8
8
using System ;
9
9
using System . Windows . Input ;
10
+ using GitHub . VisualStudio . UI . Helpers ;
10
11
11
12
namespace GitHub . VisualStudio . UI . Views
12
13
{
@@ -17,33 +18,9 @@ public GitHubConnectContent()
17
18
InitializeComponent ( ) ;
18
19
19
20
DataContextChanged += ( s , e ) => ViewModel = e . NewValue as IGitHubConnectSection ;
20
- repositories . PreviewMouseWheel += Repositories_PreviewMouseWheel ;
21
+ repositories . PreviewMouseWheel += ScrollViewerUtilities . FixMouseWheelScroll ;
21
22
}
22
23
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
- }
47
24
void cloneLink_Click ( object sender , RoutedEventArgs e )
48
25
{
49
26
cloneLink . IsEnabled = false ;
You can’t perform that action at this time.
0 commit comments