How to set a minimum size of an entire Silverlight application? RRS feed

  • Question

  • Hello,

    I would like to ask if anyone knows how I can set a minimum size to my silverlight application.

    What i want it to do is:

    When a user tries to resize the application's window it will do so but when it reaches that minimum size the window will not go over that size anymore.



    Friday, December 16, 2011 3:20 PM


  • Couple ways of accomplishing this;

    You can specify MinHeight & MinWidth properties on the container controls of your RootVisual elements like MinWidth="500" MinHeight="500" etc. Or just set "hard" Height/Widths.


    If it's an OOB app it will require elevated trust. Attach SizeChanged event of the FrameworkElement being using for the app's RootVisual (default MainPage.xaml) with handler:

     if (Application.MainWindow.Width < myMinWidth)
    Application.MainWindow.Width = myMinWidth;

    if (Application.MainWindow.Height < myMinHeight)
    Application.MainWindow.Height = myMinHeight;
    • Marked as answer by sk8ter89 Monday, December 19, 2011 3:44 PM
    Friday, December 16, 2011 3:40 PM