Skip to content

Commit 5c92fbd

Browse files
committed
fix: MinWidth not work while manually resizing window (#619)
Signed-off-by: leo <[email protected]>
1 parent ee20eba commit 5c92fbd

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

src/Views/StashesPage.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
1010
x:Class="SourceGit.Views.StashesPage"
1111
x:DataType="vm:StashesPage">
12-
<Grid>
12+
<Grid SizeChanged="OnMainLayoutSizeChanged">
1313
<Grid.ColumnDefinitions>
1414
<ColumnDefinition Width="{Binding Source={x:Static vm:Preference.Instance}, Path=Layout.StashesLeftWidth, Mode=TwoWay}" MinWidth="300"/>
1515
<ColumnDefinition Width="4"/>

src/Views/StashesPage.axaml.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,20 @@ public StashesPage()
99
InitializeComponent();
1010
}
1111

12+
private void OnMainLayoutSizeChanged(object sender, SizeChangedEventArgs e)
13+
{
14+
var grid = sender as Grid;
15+
if (grid == null)
16+
return;
17+
18+
var layout = ViewModels.Preference.Instance.Layout;
19+
var width = grid.Bounds.Width;
20+
var maxLeft = width - 304;
21+
22+
if (layout.StashesLeftWidth.Value - maxLeft > 1.0)
23+
layout.StashesLeftWidth = new GridLength(maxLeft, GridUnitType.Pixel);
24+
}
25+
1226
private void OnStashContextRequested(object sender, ContextRequestedEventArgs e)
1327
{
1428
if (DataContext is ViewModels.StashesPage vm && sender is Border border)

src/Views/WorkingCopy.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="600"
99
x:Class="SourceGit.Views.WorkingCopy"
1010
x:DataType="vm:WorkingCopy">
11-
<Grid>
11+
<Grid SizeChanged="OnMainLayoutSizeChanged">
1212
<Grid.ColumnDefinitions>
1313
<ColumnDefinition Width="{Binding Source={x:Static vm:Preference.Instance}, Path=Layout.WorkingCopyLeftWidth, Mode=TwoWay}" MinWidth="300"/>
1414
<ColumnDefinition Width="5"/>

src/Views/WorkingCopy.axaml.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@ public WorkingCopy()
1111
InitializeComponent();
1212
}
1313

14+
private void OnMainLayoutSizeChanged(object sender, SizeChangedEventArgs e)
15+
{
16+
var grid = sender as Grid;
17+
if (grid == null)
18+
return;
19+
20+
var layout = ViewModels.Preference.Instance.Layout;
21+
var width = grid.Bounds.Width;
22+
var maxLeft = width - 304;
23+
24+
if (layout.WorkingCopyLeftWidth.Value - maxLeft > 1.0)
25+
layout.WorkingCopyLeftWidth = new GridLength(maxLeft, GridUnitType.Pixel);
26+
}
27+
1428
private void OnOpenCommitMessagePicker(object sender, RoutedEventArgs e)
1529
{
1630
if (sender is Button button && DataContext is ViewModels.WorkingCopy vm)

0 commit comments

Comments
 (0)