WPF方向 [英] WPF Orientation

查看:148
本文介绍了WPF方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在以纵向模式在平板电脑上开发应用程序.

I'm developing an application on a tablet with portrait orientation.

但是,当数位板转到横向模式时,应用程序也会打开,并且所有对齐方式都将被抛弃.那么,有什么方法可以将WPF应用程序锁定为一个方向?

However, when the tablet is turned to landscape mode, the application also turns, and all the alignments are thrown off. So is there any way I can lock my WPF application to a single orientation?

谢谢!

推荐答案

我必须同意 Martin :我本人已经开发了Tablet PC Apps,您应该提供一个在横向和纵向下都能很好地工作的布局.

I have to agree with Martin: I have developed Tablet PC Apps myself and you should rather provide a layout that works well in landscape and portrait.

除此之外,您还可以通过以下方式检测方向变化:

Besides from that you can detect the change in orientation this way:

Microsoft.Win32.SystemEvents.DisplaySettingsChanged += new EventHandler(SystemEvents_DisplaySettingsChanged);
}

void SystemEvents_DisplaySettingsChanged(object sender, EventArgs e)
{
  if (SystemParameters.PrimaryScreenWidth > SystemParameters.PrimaryScreenHeight)
  {
    // runs in landscape
  }
  else
  {
    // runs in portrait
  }
}

这篇关于WPF方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆