簡體   English   中英

如何在Xamarin WPF上刪除標題欄並使應用程序全屏顯示

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

如何在Xamarin WPF上刪除標題欄並使應用程序全屏顯示?

xamarin wpf全屏的行為與原始wpf應用程序不同。 當我通過啟用全屏模式時

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

該應用程序實際上並未刪除標題欄並隱藏任務欄。

有什么方法可以實現與本機WPF應用程序相同的行為?

下面的示例

這就是我刪除Xamarin.Forms創建的所有條的方式(在v3.2中進行了測試):

  1. 在WPF本機項目中,轉到MainWindow.xaml.cs
  2. 添加刪除方法:

      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. 調用方法:

 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