Skip to content

Commit

Permalink
Merge pull request #5532 from MDoerner/SuppressHorizontalBringIntoVie…
Browse files Browse the repository at this point in the history
…wInGroupinGrids

Suppress only horizontal scroll in inspection results window and test explorer
  • Loading branch information
retailcoder committed Jul 4, 2020
2 parents 8011485 + 4b01a60 commit 2581512
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
Expand Up @@ -201,6 +201,7 @@
SelectionUnit="FullRow"
ItemsSource="{Binding Results, NotifyOnSourceUpdated=True}"
VirtualizingPanel.IsVirtualizingWhenGrouping="True"
RequestBringIntoView="InspectionResultsGrid_RequestBringIntoView"
ScrollViewer.CanContentScroll="True"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
Expand Down
24 changes: 22 additions & 2 deletions Rubberduck.Core/UI/Inspections/InspectionResultsControl.xaml.cs
@@ -1,20 +1,40 @@
namespace Rubberduck.UI.Inspections
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();
}

private void InspectionResultsGrid_RequestBringIntoView(object sender, System.Windows.RequestBringIntoViewEventArgs e)
//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;
}
}
}
1 change: 1 addition & 0 deletions Rubberduck.Core/UI/UnitTesting/TestExplorerControl.xaml
Expand Up @@ -334,6 +334,7 @@
ShowGroupingItemCount="True"
InitialExpandedState="True"
VirtualizingPanel.IsVirtualizingWhenGrouping="True"
RequestBringIntoView="TestGrid_RequestBringIntoView"
ScrollViewer.CanContentScroll="False"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
Expand Down
24 changes: 22 additions & 2 deletions Rubberduck.Core/UI/UnitTesting/TestExplorerControl.xaml.cs
@@ -1,18 +1,38 @@
namespace Rubberduck.UI.UnitTesting
using System.Windows;

namespace Rubberduck.UI.UnitTesting
{
/// <summary>
/// Interaction logic for TestExplorerControl.xaml
/// </summary>
public partial class TestExplorerControl
{
private const int HorizontalRectangleAdjustment = 2000;

public TestExplorerControl()
{
InitializeComponent();
}

private void TestGrid_RequestBringIntoView(object sender, System.Windows.RequestBringIntoViewEventArgs e)
//Based on https://stackoverflow.com/a/42238409/5536802 by Jason Williams and the comment to it by Nick Desjardins.
private bool _requestingModifiedBringIntoView;
private void TestGrid_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;
}
}
}

0 comments on commit 2581512

Please sign in to comment.