title: How can I set me UWP page to have a constant width and height at startup?
body: <p>I am creating a UWP app using C++ and XAML. How can I set the app's width and height to be constant?</p>
  
  <p>I am completely new to XAML and I want to create a UWP app using C++/WinRT. I have set the page's width to 500 and the height to 200 but if I resize the page during runtime, and then I restart the app, the size of the page will still be the resized size. For example if I resize the page's width and height too 1000 during runtime (using my cursor to drag the page), when I then restart the app, the page's width and height will still be 1000.</p>
  
  <p>Here is my main.cpp:</p>
  
  <pre><code>#include "pch.h"
  
  using namespace winrt;
  
  using namespace Windows::ApplicationModel;
  using namespace Windows::ApplicationModel::Activation;
  using namespace Windows::Foundation;
  using namespace Windows::Storage;
  using namespace Windows::UI::Xaml;
  using namespace Windows::UI::Xaml::Controls;
  using namespace Windows::UI::Xaml::Markup;
  
  struct App : ApplicationT&lt;App&gt; {
      fire_and_forget OnLaunched(const LaunchActivatedEventArgs&amp;) {
          const auto packageFolder = Package::Current().InstalledLocation();
          const auto file = co_await packageFolder.GetFileAsync(L"MainPage.xaml");
          const auto xaml = co_await FileIO::ReadTextAsync(file);
  
          const auto body = XamlReader::Load(xaml).as&lt;Page&gt;();
  
          auto window = Window::Current();
          window.Content(body);
          window.Activate();
      }
  };
  
  int __stdcall wWinMain(HINSTANCE, HINSTANCE, PWSTR, int) {
      Application::Start([](auto&amp;&amp;) {make&lt;App&gt;(); });
  }
  </code></pre>
  
  <p>And here is my MainPage.xaml:</p>
  
  <pre><code>&lt;Page
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
   xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
   mc:Ignorable="d"
   Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" 
   Width="500" Height="200"&gt;
  
  &lt;Grid HorizontalAlignment="Stretch" Margin="0,0,408,0" 
  VerticalAlignment="Stretch"/&gt;
  &lt;/Page&gt;
  </code></pre>
  
  <p>I would want the app to restore its size each time a start the app. So the width should always be 500 and the height should always be 200 on startup. I have no idea why this happens since I am completely new to this so any help would be appreciated.</p>
  
  <p>Thanks.</p>
  
  <p>Additionally I would want a fixed size of the page during runtime, meaning that the page will not be able to resize during runtime.</p>