/
InspectionResultsControl.xaml.cs
40 lines (32 loc) · 1.35 KB
/
InspectionResultsControl.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System.Windows;
namespace Rubberduck.UI.Inspections
{
/// <summary>
/// Interaction logic for InspectionResultsControl.xaml
/// </summary>
public partial class InspectionResultsControl
{
private const int HorizontalRectangleAdjustment = 2000;
private InspectionResultsViewModel ViewModel => DataContext as InspectionResultsViewModel;
public InspectionResultsControl()
{
InitializeComponent();
}
//Based on https://stackoverflow.com/a/42238409/5536802 by Jason Williams and the comment to it by Nick Desjardins.
private bool _requestingModifiedBringIntoView;
private void InspectionResultsGrid_RequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
{
if (_requestingModifiedBringIntoView
|| !(e?.OriginalSource is FrameworkElement source))
{
return;
}
e.Handled = true;
//Prevents adjustment of the adjusted event triggered below.
_requestingModifiedBringIntoView = true;
var newRectangle = new Rect(-HorizontalRectangleAdjustment, 0, source.ActualWidth + HorizontalRectangleAdjustment, source.ActualHeight);
source.BringIntoView(newRectangle);
_requestingModifiedBringIntoView = false;
}
}
}