简体   繁体   English

如何在Xamarin WPF上删除标题栏并使应用程序全屏显示

[英]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? 如何在Xamarin WPF上删除标题栏并使应用程序全屏显示?

Behavior of xamarin wpf full screen is different from original wpf application. xamarin wpf全屏的行为与原始wpf应用程序不同。 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 ? 有什么方法可以实现与本机WPF应用程序相同的行为?

下面的示例

That's how I removed all the bars create by Xamarin.Forms (tested in v3.2): 这就是我删除Xamarin.Forms创建的所有条的方式(在v3.2中进行了测试):

  1. In WPF native project go to MainWindow.xaml.cs 在WPF本机项目中,转到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(); } 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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