[HELP] Set Minimum width for the Shell #13066
-
Hello everyone, I try to set a the minimum width for my application but it doesn't work. Then I discovered this discussion about setting a fixed size at the startup : #2370. So I understood, it will no be as simple to set the minimum. For UWP, I found how to do what I want : microsoft/microsoft-ui-xaml#2945. But I cannot succeed to implement this in my "App.xaml.cs" in my directory Windows platform. Someone can help me ? :) Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I am also looking for an answer for this problem. I looked at #2370 and if you reach the point when you have a variable with private static void NativeWindow_SizeChanged(object sender, Microsoft.UI.Xaml.WindowSizeChangedEventArgs args)
{
if (args.Size.Width * 1.05 < 896)
{
int height = (int)(args.Size.Height * DeviceDisplay.MainDisplayInfo.Density);
AppWindow.Resize(new(896, height));
}
if (args.Size.Height * 1.05 < 720)
{
int width = (int)(args.Size.Width * DeviceDisplay.MainDisplayInfo.Density);
AppWindow.Resize(new(width, 720));
}
args.Handled = true;
} It doesn't look as it should for a desktop app, it can be made smaller and just springs back into the "minimum size", but at least its something... |
Beta Was this translation helpful? Give feedback.
I am also looking for an answer for this problem. I looked at #2370 and if you reach the point when you have a variable with
AppWindow
, then you can hook up to theAppWindow.SizeChanged += NativeWindow_SizeChanged;
event and in there protect from being too small: