How to set fixed window size for Universal Windows Application

前端 未结 3 1989
长情又很酷
长情又很酷 2021-01-06 01:21

I just started to develop an Universal Windows Application in VS2015 Community Edition. I have used the sample called PieCharts for Windows UWP.

My problem is that

相关标签:
3条回答
  • 2021-01-06 01:55

    I found a solution. I think its not the best, but it works.
    XAML:

         <Grid Background="#4A9130" SizeChanged="FormName_SizeChanged">
    

    c#

        private void FormName_SizeChanged(object sender, SizeChangedEventArgs e)
        {
    
            ApplicationView.GetForCurrentView().TryResizeView(new Size(900, 600));
        }
    

    Hope it helps

    0 讨论(0)
  • 2021-01-06 01:57

    You can use this code for set minimal size of application: ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(400, 650));

    0 讨论(0)
  • 2021-01-06 02:06

    I guess the only choice is use OnSizeChanged Method to control size of window. It's work's for me. Maybe not the best choice but really easy way to solve problem.

    private void FormName_SizeChanged(object sender, SizeChangedEventArgs e)
    {
        if((this.Width != 400) & (this.Height != 650))
        {
            this.Width = 450;
            this.Height = 650;
        }
    }
    
    0 讨论(0)
提交回复
热议问题