Windows 10 (3) and Windows 10

Source: Internet
Author: User

Windows 10 (3) and Windows 10

[Download source code]


Backwater world war I Windows 10 (3)-UI: full screen window, window size



Author: webabcd


Introduction
UI of Windows 10

  • Window full screen
  • Window Size



Example
1. Full Screen Window
UI/FullScreen. xaml

<Page x: Class = "Windows10.UI. FullScreen" xmlns =" http://schemas.microsoft.com/winfx/2006/xaml /Presentation "xmlns: x =" http://schemas.microsoft.com/winfx/2006/xaml "Xmlns: local =" using: Windows10.UI "xmlns: d =" http://schemas.microsoft.com/expression/blend/2008 "Xmlns: mc =" http://schemas.openxmlformats.org/markup-compatibility/2006 "Mc: ignorable = "d"> <Grid Background = "Transparent"> <StackPanel Margin = "10 0 10"> <TextBlock Name = "lblMsg" Margin = "0 10 0 0" /> <Button Name = "btnFullScreen" Content = "full screen/cancel full screen" Click = "btnFullScreen_Click" Margin = "0 10 0 0"/> <Button Name = "btnShowStandardSystemOverlays" Content = "in full screen mode, display the system UI, such as the title bar and Taskbar "Click =" btnShowStandardSystemOverlays_Click "Margin =" 0 10 0 0 "/> <CheckBox Name =" chkFullScreenSystemOverlayMode "Content =" full screen, response Mode of the system edge gesture unchecked: FullScreenSystemOverlayMode. standard, checked: FullScreenSystemOverlayMode. minimal "Click =" cursor "Margin =", "/> <CheckBox Name =" chkpreferredlaunch?wingmode "Content =" window Startup Mode unchecked: applicationview=wingmode. auto, unchecked: ApplicationViewWindowingMode. fullScreen "Click =" chkpreferredlaunch?wingmode_click "Margin =", "/> </StackPanel> </Grid> </Page>

UI/FullScreen. xaml. cs

/** Demonstrate "window full screen" related knowledge ** ApplicationView-used to operate Windows and obtain window information * GetForCurrentView ()-return ApplicationView instance */using Windows. system; using Windows. UI. viewManagement; using Windows. UI. xaml; using Windows. UI. xaml. controls; using Windows. UI. xaml. input; using Windows. UI. xaml. navigation; namespace Windows10.UI {public sealed partial class FullScreen: Page {private MainPage _ rootPage; public FullScreen () {this. ini TializeComponent (); this. loaded + = FullScreen_Loaded;} private void FullScreen_Loaded (object sender, RoutedEventArgs e) {/** ApplicationView. preferredLaunchWindowingMode-window Startup Mode * Auto-the system automatically determines * PreferredLaunchViewSize-by ApplicationView. preferredLaunchViewSize is determined (see UI/ScreenSize. xaml) * FullScreen-full screen startup ** ApplicationView. getForCurrentView (). fullScreenSystemOverlayMode-system edge gesture in full screen mode Mode * Standard-Standard mode. For example, move the cursor to the top and display the title bar. move the cursor to the bottom to display the taskbar * Minimal-min mode. For example, if you move the mouse to the top, a small temporary UI is displayed. When you click this temporary UI, the title bar or taskbar is displayed * // unchecked: FullScreenSystemOverlayMode. standard, checked: FullScreenSystemOverlayMode. minimal chkFullScreenSystemOverlayMode. isChecked = ApplicationView. getForCurrentView (). fullScreenSystemOverlayMode = FullScreenSystemOverlayMode. minimal; // unchecked: ApplicationViewWindowingMode. auto, unchecked: ApplicationViewWindowingMode. fullScree N chkpreferredlaunchw.wingmode. isChecked = ApplicationView. preferredLaunchWindowingMode = ApplicationViewWindowingMode. fullScreen;} protected override void OnNavigatedTo (NavigationEventArgs e) {_ rootPage = MainPage. current; _ rootPage. keyDown + = _ rootPage_KeyDown;} protected override void OnNavigatedFrom (NavigationEventArgs e) {_ rootPage. keyDown-= _ rootPage_KeyDown;} private void _ rootPag E_KeyDown (object sender, KeyRoutedEventArgs e) {// determines whether the escape key if (e. key = VirtualKey. escape) {var view = ApplicationView. getForCurrentView (); if (view. isFullScreenMode) {// exit full screen view. exitFullScreenMode () ;}} private void btnFullScreen_Click (object sender, RoutedEventArgs e) {ApplicationView view = ApplicationView. getForCurrentView (); // determines whether the current full screen mode is true if (view. isFullScreenMode) {// return View in full screen mode. exitFullScreenMode (); lblMsg. text = "exit full screen mode";} else {// try to enter full screen mode bool isSuccess = view. tryEnterFullScreenMode (); if (isSuccess) {lblMsg. text = "entering full screen mode";} else {lblMsg. text = "failed to enter full screen mode" ;}} private void btnShowStandardSystemOverlays_Click (object sender, RoutedEventArgs e) {ApplicationView view = ApplicationView. getForCurrentView (); // whether the system UI is displayed in full screen mode, such as the title bar and taskbar view. showStanda RdSystemOverlays ();} private void upload (object sender, RoutedEventArgs e) {ApplicationView view = ApplicationView. GetForCurrentView (); view. FullScreenSystemOverlayMode = callback. IsChecked. Value? FullScreenSystemOverlayMode. Minimal: FullScreenSystemOverlayMode. Standard;} private void upload (object sender, RoutedEventArgs e) {ApplicationView. preferredlaunch{wingmode = forbidden. IsChecked. Value? ApplicationViewWindowingMode. FullScreen: ApplicationViewWindowingMode. Auto ;}}}


2. Window Size
UI/ScreenSize. xaml

<Page x: Class = "Windows10.UI. screenSize "xmlns =" http://schemas.microsoft.com/winfx/2006/xaml/presentation "xmlns: x =" http://schemas.microsoft.com/winfx/2006/xaml "xmlns: local =" using: Windows10.UI "xmlns: d =" http://schemas.microsoft.com/expression/blend/2008 "xmlns: mc =" http://schemas.openxmlformats.org/markup-compatibility/2006 "mc: ignorable = "d"> <Grid Background = "Transparent"> <StackPanel Margin = "10 0 10"> <TextBlock Name = "lblMsg" Margin = "0 10 0 0" /> <Button Name = "btnChangeSize" Content = "try to change the window size" Click = "btnChangeSize_Click" Margin = "0 10 0 0"/> </StackPanel> </Grid> </Page>

UI/ScreenSize. xaml. cs

/** Demonstrate "window size" knowledge points ** ApplicationView-used to operate Windows and obtain window information * GetForCurrentView ()-return ApplicationView instance */using Windows. foundation; using Windows. UI. viewManagement; using Windows. UI. xaml; using Windows. UI. xaml. controls; using Windows. UI. xaml. navigation; namespace Windows10.UI {public sealed partial class ScreenSize: Page {public ScreenSize () {this. initializeComponent (); this. loaded + = ScreenSize_Loaded ;} Private void ScreenSize_Loaded (object sender, RoutedEventArgs e) {// Window. current. bounds-size of the current window (unit: Valid pixels, all valid pixels without special instructions) // note: the window size does not include the title bar. The title bar belongs to the system-level UI lblMsg. text = string. format ("window size: {0} * {1}", Window. current. bounds. width, Window. current. bounds. height); ApplicationView applicationView = ApplicationView. getForCurrentView (); // SetPreferredMinSize (Size minSize)-specify the minimum Size allowed by the window // minimum w Idth and minimum height cannot be zero. Here I test that the minimum width is 192, and the minimum height is 48 applicationView. setPreferredMinSize (new Size (200,200); // PreferredLaunchViewSize-the initial Size of the window at startup // you need to set the PreferredLaunchViewSize to be valid. set PreferredLaunchWindowingMode to ApplicationViewWindowingMode. preferredLaunchViewSize ApplicationView. preferredLaunchViewSize = new Size (800,480); ApplicationView. preferredLaunchWindowing Mode = ApplicationViewWindowingMode. preferredLaunchViewSize;/** ApplicationView. preferredLaunchWindowingMode-window Startup Mode * Auto-the system automatically adjusts * PreferredLaunchViewSize-by ApplicationView. preferredLaunchViewSize determines * FullScreen-full screen startup */} protected override void OnNavigatedTo (NavigationEventArgs e) {// event Window triggered when the Window size changes. current. sizeChanged + = Current_SizeChanged;} protected override void OnNavig AtedFrom (NavigationEventArgs e) {Window. current. sizeChanged-= Current_SizeChanged;} private void Current_SizeChanged (object sender, Windows. UI. core. windowSizeChangedEventArgs e) {lblMsg. text = string. format ("window size: {0} * {1}", e. size. width, e. size. height);} private void btnChangeSize_Click (object sender, RoutedEventArgs e) {ApplicationView applicationView = ApplicationView. getForCurren TView (); Size size Size = new Size (600,600); // TryResizeView (Size value)-try to set the window size to the specified Size bool success = applicationView. tryResizeView (size); if (success) {lblMsg. text = "window size modified successfully";} else {lblMsg. text = "An error occurred while trying to modify the window size";} // Note: How can I modify the display position of the window? Do not know yet }}}



OK
[Download source code]

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.