问题描述
我刚刚开始在VS2015 Community Edition中开发通用Windows应用程序.我使用了名为PieCharts的Windows UWP示例.
I just started to develop an Universal Windows Application in VS2015 Community Edition. I have used the sample called PieCharts for Windows UWP.
我的问题是,我想像在旧的桌面应用程序中一样将窗口大小固定为400x650.我已经手动设置了宽度和高度,这是行不通的.我的MainPage.xaml类似于以下代码.
My problem is that I whould like to fix the window size to 400x650 as I did in my old desktop applications. I have set Width and Height manually It does not work. My MainPage.xaml is something like the following code.
<Page x:Class="MyFistUWP.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyFistUWP"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
MaxHeight="650" MinHeight="650" MaxWidth="400" MinWidth="400" Height="650" Width="400" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="140" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Image Grid.Row="0" Source="Resources/my_logo.png" />
</Grid>
窗口大小错误,我可以调整窗口大小.
The window size is wrong and I can resize window.
谢谢
推荐答案
我找到了解决方案.我认为它不是最好的,但它可以工作.
XAML:
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));
}
希望有帮助
这篇关于如何为通用Windows应用程序设置固定的窗口大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!