【发布时间】:2017-04-21 05:38:57
【问题描述】:
我使用 C# 和 XAML,我的主页是这样开始的:
<Page
x:Class="MyApp.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyApp"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Height="754" Width="1018" MaxHeight="754" MaxWidth="1018" MinHeight="754" MinWidth="1018"
mc:Ignorable="d">
<Grid>
(...)
</Grid>
但是当我启动应用程序时,窗口总是最大化。只有网格遵守 XAML 中提到的大小。我在这个论坛上阅读了一些答案,但是我在编写时遇到了编译错误:
ResizeMode="NoResize"
在 XAML 代码中,或
Application.Current.MainWindow.Height = 754;
在 C# 代码中(因为 Application.Current 是已知的,但不是 Application.Current.MainWindow)。
我不明白为什么这些解决方案对我不起作用。我也能看到这个:
WindowState="Maximized"
ResizeMode="NoResize"
WindowStyle="None"
它也不起作用:“它在上下文中不存在”。怎么了?
【问题讨论】:
标签: c# xaml uwp windows-10-universal uwp-xaml