简体   繁体   中英

How to remove title bar on xamarin wpf and make the application full screen

How to remove title bar on xamarin wpf and make the application full screen?

Behavior of xamarin wpf full screen is different from original wpf application. When i enable the full screen mode by

ResizeMode="NoResize", WindowState="Normal", WindowStyle="None", Topmost="True", WindowState = "Maximized";

The application is not actually remove the titlebar and hide the taskbar.

Is there any way to achieve same behavior as native WPF application ?

下面的示例

That's how I removed all the bars create by Xamarin.Forms (tested in v3.2):

  1. In WPF native project go to MainWindow.xaml.cs
  2. Add the remove method:

      private bool topBarsRemoved = false; private void RemoveTopBars() { System.Windows.Controls.Grid commandBar = this.Template.FindName("PART_CommandsBar", this) as System.Windows.Controls.Grid; if (commandBar != null) (commandBar.Parent as System.Windows.Controls.Grid)?.Children.Remove(commandBar); var topAppBar = this.Template.FindName("PART_TopAppBar", this) as WpfLightToolkit.Controls.LightAppBar; if (topAppBar != null) (topAppBar.Parent as System.Windows.Controls.Grid)?.Children.Remove(topAppBar); topBarsRemoved = true; } 
  3. Call the method:

 protected override void OnActivated(EventArgs e) { base.OnActivated(e); if (!topBarsRemoved) RemoveTopBars(); } 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM