Skip to content

Commit c940770

Browse files
authored
Fix preview size (#9126)
1 parent 490c143 commit c940770

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

src/Files.Uwp/Views/MainPage.xaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
Background="Transparent"
2020
KeyboardAcceleratorPlacementMode="Hidden"
2121
Loaded="Page_Loaded"
22+
SizeChanged="Page_SizeChanged"
2223
NavigationCacheMode="Required"
2324
mc:Ignorable="d">
2425
<Page.DataContext>
@@ -371,13 +372,13 @@
371372

372373
<Grid.RowDefinitions>
373374
<RowDefinition Height="Auto" />
374-
<RowDefinition Height="*" MinHeight="100" />
375+
<RowDefinition x:Name="ContentRow" Height="*" MinHeight="100" />
375376
<RowDefinition Height="Auto" />
376377
<RowDefinition x:Name="PaneRow" Height="Auto" />
377378
<RowDefinition Height="32" />
378379
</Grid.RowDefinitions>
379380
<Grid.ColumnDefinitions>
380-
<ColumnDefinition Width="3*" MinWidth="100" />
381+
<ColumnDefinition x:Name="ContentColumn" Width="*" MinWidth="100" />
381382
<ColumnDefinition Width="Auto" />
382383
<ColumnDefinition x:Name="PaneColumn" Width="Auto" />
383384
</Grid.ColumnDefinitions>

src/Files.Uwp/Views/MainPage.xaml.cs

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using CommunityToolkit.Mvvm.DependencyInjection;
22
using CommunityToolkit.Mvvm.Input;
3+
using Files.Backend.Extensions;
34
using Files.Backend.Services.Settings;
45
using Files.Shared.Enums;
56
using Files.Shared.EventArguments;
@@ -27,7 +28,6 @@
2728
using Windows.UI.Xaml.Controls;
2829
using Windows.UI.Xaml.Input;
2930
using Windows.UI.Xaml.Navigation;
30-
using Files.Backend.Extensions;
3131

3232
namespace Files.Uwp.Views
3333
{
@@ -383,6 +383,21 @@ private void Page_Loaded(object sender, RoutedEventArgs e)
383383
}
384384
}
385385

386+
private void Page_SizeChanged(object sender, SizeChangedEventArgs e)
387+
{
388+
switch (Pane?.Position)
389+
{
390+
case PanePositions.Right when ContentColumn.ActualWidth == ContentColumn.MinWidth:
391+
UserSettingsService.PaneSettingsService.VerticalSizePx += e.NewSize.Width - e.PreviousSize.Width;
392+
UpdatePositioning();
393+
break;
394+
case PanePositions.Bottom when ContentRow.ActualHeight == ContentRow.MinHeight:
395+
UserSettingsService.PaneSettingsService.HorizontalSizePx += e.NewSize.Height - e.PreviousSize.Height;
396+
UpdatePositioning();
397+
break;
398+
}
399+
}
400+
386401
private void ToggleFullScreenAccelerator(KeyboardAcceleratorInvokedEventArgs e)
387402
{
388403
ApplicationView view = ApplicationView.GetForCurrentView();
@@ -474,17 +489,14 @@ private void UpdatePositioning()
474489

475490
private void PaneSplitter_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
476491
{
477-
if (Pane is IPane p)
492+
switch (Pane?.Position)
478493
{
479-
switch (p.Position)
480-
{
481-
case PanePositions.Right:
482-
UserSettingsService.PaneSettingsService.VerticalSizePx = Pane.ActualWidth;
483-
break;
484-
case PanePositions.Bottom:
485-
UserSettingsService.PaneSettingsService.HorizontalSizePx = Pane.ActualHeight;
486-
break;
487-
}
494+
case PanePositions.Right:
495+
UserSettingsService.PaneSettingsService.VerticalSizePx = Pane.ActualWidth;
496+
break;
497+
case PanePositions.Bottom:
498+
UserSettingsService.PaneSettingsService.HorizontalSizePx = Pane.ActualHeight;
499+
break;
488500
}
489501
}
490502

0 commit comments

Comments
 (0)