【问题标题】:How to remove title bar on xamarin wpf and make the application full screen如何删除 xamarin wpf 上的标题栏并使应用程序全屏显示
【发布时间】:2019-01-11 05:53:18
【问题描述】:

如何去除 xamarin wpf 上的标题栏并使应用全屏显示?

xamarin wpf 全屏的行为与原始 wpf 应用程序不同。 当我通过

启用全屏模式时

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

应用程序实际上并没有移除标题栏并隐藏任务栏。

有没有办法实现与原生 WPF 应用程序相同的行为?

【问题讨论】:

  • 可能NavigationPage.HasNavigationBar="False"会帮助你
  • @JoãoFernandes 不,不工作。
  • 只是一个想法,但在您的问题中,您有 WindowState= Normal 和 WindowState=Maximized 但您是否将其设置为无边框形式?

标签: c# wpf xamarin desktop-application


【解决方案1】:

这就是我删除 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();
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-12-27
    • 1970-01-01
    • 2021-09-02
    • 2021-07-27
    • 2011-08-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多