【问题标题】:How can I set the Windows position on startup如何在启动时设置 Windows 位置
【发布时间】:2017-06-24 06:44:43
【问题描述】:

我想将窗口在屏幕右侧的位置设置为类似于WPF。 UWP 中有没有办法做到这一点?

【问题讨论】:

    标签: c# visual-studio uwp windows-10-universal


    【解决方案1】:

    AFAIK 这在 UWP 中是不可能的(至少现在还不可能),您可以通过访问 ApplicationView 类来更改窗口大小或使其全屏显示,但没有像 中这样的方法/属性em>WPF.

    还有similar question on MSDN

    【讨论】:

      【解决方案2】:

      是的,有一种方法 :) 转到您的 xaml,例如 Windows1.xaml

      然后把它放在那里。示例代码

       <Window
      x:Class="Poultry_Management_System.Window1"      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Title="Login"
      Width="450"
      WindowStartupLocation="CenterScreen"
      WindowStyle="None"
      ResizeMode="NoResize"
      Topmost="True"
      KeyDown="keyDown_form"
      Height="200">
      

      如您所见,我的 StartupLocation 位于中心。

      【讨论】:

      • 感谢您的回答!如果我想以编程方式设置窗口位置怎么办?
      • 那么您应该彻底阅读有关事件基础操作的信息。这方面的例子很多
      • 你确定这是为 UWP 设计的吗?
      • 顺便说一下,你的解决方案也适用于 WPF,UWP 使用 :)
      • @RandomUser 其中 UWP 中的 WindowStartupLocation?
      猜你喜欢
      • 2011-12-18
      • 2017-03-05
      • 2014-10-19
      • 1970-01-01
      • 2012-12-06
      • 2010-10-15
      • 2017-03-19
      相关资源
      最近更新 更多