How to hide task bar and maximize window using WPF through Xamarin Forms

夙愿已清 提交于 2021-01-29 11:46:37

问题


I have already tried different options including info in this question Make my wpf application Full Screen (Cover taskbar and title bar of window), but nothing helped me Only IgnoreTaskbarOnMaximize property works correct, but it is used from the MahApps, which is not compatible with Xamarin Forms. Maybe you know how to implement IgnoreTaskbarOnMaximize manually?


回答1:


As far as I can tell from this tutorial on using Xamarin.Forms with WPF, the Xamarin.Forms application is created from a Window

public partial class MainWindow : FormsApplicationPage
{
    public MainWindow()
    {
        InitializeComponent();
        Forms.Init();
        LoadApplication(new My.App());
    }
}

with or without the respective XAML file (should not matter that much, unless the InitializeComponent is not called without a XAML file). If there is a XAML file for your window, I'd suppose that this solution would work out

<wpf:FormsApplicationPage ResizeMode="NoResize" WindowState="Maximized"  ...>
<!-- Not sure whether the grid is needed in here -->
</wpf:FormsApplicationPage>

otherwise you'd have to set the properties from your window class

public class MainWindow : FormsApplicationPage
{
    public MainWindow()
    {
        // whatever there is to be done before

        this.ResizeMode = ResizeMode.NoResize;
        this.WindowState = WindowState.Maximized;

        Forms.Init();
        LoadApplication(new My.App());
    }
}



回答2:


The solution is quite simple. If you want to make your application full screen (with taskbar covering) don't set WindowState to Maximized, just change Width and Height like this after InitializeComponent();

public MainWindow()
{
  InitializeComponent();

  Top = 0;
  Left = 0;
  Height = SystemParameters.PrimaryScreenHeight;
  Width = SystemParameters.PrimaryScreenWidth;

  Forms.Init();
  LoadApplication(new SharedForms.App());
}


来源:https://stackoverflow.com/questions/60397541/how-to-hide-task-bar-and-maximize-window-using-wpf-through-xamarin-forms

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!