Emilia Larssen
Emilia Larssen

Reputation: 105

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

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?

Upvotes: 0

Views: 629

Answers (2)

Emilia Larssen
Emilia Larssen

Reputation: 105

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());
}

Upvotes: 0

Paul Kertscher
Paul Kertscher

Reputation: 9742

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());
    }
}

Upvotes: 1

Related Questions