From 21c37161c67bb46965752226287dbc858d4cf124 Mon Sep 17 00:00:00 2001 From: Jacob Colyer Date: Tue, 9 Oct 2018 13:28:08 -0400 Subject: [PATCH] Fixes issue #1379 in xceedsoftware/wpftoolkit Conform to the data contract for GridLength constructor and provide a valid double value when using the grid splitter to resize layout panes. In certain situations, a user can resize panes into negative space which is not valid. --- .../Controls/LayoutGridControl.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutGridControl.cs b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutGridControl.cs index 0f8960d6..cb1c1853 100644 --- a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutGridControl.cs +++ b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutGridControl.cs @@ -416,7 +416,8 @@ namespace Xceed.Wpf.AvalonDock.Controls else { var width = ( prevChildModel.DockWidth.IsAuto ) ? prevChildActualSize.Width : prevChildModel.DockWidth.Value; - prevChildModel.DockWidth = new GridLength( width + delta, GridUnitType.Pixel ); + var resizedWidth = width + delta; + prevChildModel.DockWidth = new GridLength( double.IsNaN(resizedWidth) ? width : resizedWidth, GridUnitType.Pixel ); } if( nextChildModel.DockWidth.IsStar ) @@ -426,7 +427,8 @@ namespace Xceed.Wpf.AvalonDock.Controls else { var width = ( nextChildModel.DockWidth.IsAuto ) ? nextChildActualSize.Width : nextChildModel.DockWidth.Value; - nextChildModel.DockWidth = new GridLength( width - delta, GridUnitType.Pixel ); + var resizedWidth = width - delta; + nextChildModel.DockWidth = new GridLength( double.IsNaN(resizedWidth) ? width : resizedWidth, GridUnitType.Pixel ); } } else @@ -438,7 +440,8 @@ namespace Xceed.Wpf.AvalonDock.Controls else { var height = ( prevChildModel.DockHeight.IsAuto ) ? prevChildActualSize.Height : prevChildModel.DockHeight.Value; - prevChildModel.DockHeight = new GridLength( height + delta, GridUnitType.Pixel ); + var resizedHeight = height + delta; + prevChildModel.DockHeight = new GridLength( double.IsNaN(resizedHeight) ? height : resizedHeight, GridUnitType.Pixel ); } if( nextChildModel.DockHeight.IsStar ) @@ -448,7 +451,8 @@ namespace Xceed.Wpf.AvalonDock.Controls else { var height = ( nextChildModel.DockHeight.IsAuto ) ? nextChildActualSize.Height : nextChildModel.DockHeight.Value; - nextChildModel.DockHeight = new GridLength( height - delta, GridUnitType.Pixel ); + var resizedHeight = height - delta; + nextChildModel.DockHeight = new GridLength( double.IsNaN(resizedHeight) ? height : resizedHeight, GridUnitType.Pixel ); } }