John Livermore
John Livermore

Reputation: 31333

Xamarin forms UWP fixed width

When run in a Windows environment a Xamarin Forms UWP app can be resized (vs a tablet environment which is always full screen).

Is there a way to set a minimum width for the window? MinimumWidthRequest on the page doesn't seem to do the job. By default the app won't go below 500px in width (not sure where that setting comes from), but I want that value to be 1000px.

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:SampleApp"
             MinimumWidthRequest="1000"
             x:Class="SampleApp.MainPage">

    <StackLayout>
        <!-- Place new controls here -->
        <Label Text="Welcome to Xamarin.Forms!" 
           HorizontalOptions="Center"
           VerticalOptions="CenterAndExpand" />
    </StackLayout>

</ContentPage>

Upvotes: 0

Views: 269

Answers (1)

Morse
Morse

Reputation: 9144

You need to do it on page renderer

within OnElementChanged add this.

ApplicationView.PreferredLaunchViewSize = new Size(1000, 1000);
ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;

Reference

Upvotes: 1

Related Questions