3

I have a WPF app that installed on Windows 10 Pro via ClickOnce and uses MahApps.Metro.

It is set to launch on Windows boot with a non-admin account that has no password. Tablet mode is enabled.

I want the application pop up full screen to create kiosk-like experience, however the app starts minimized when launching on boot. To clarify, the WindowState is Maximized, but Windows does not show it, instead it shows the start screen. It launches fullscreen maximized when launching manually.

Here is some code, however I guess this is more of a configuration problem than code problem:

This is how I set the launch on boot:

RegistryKey rkApp = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
string startPath = Environment.GetFolderPath(Environment.SpecialFolder.Programs)
                       + @"\Publisher\AppName.appref-ms";
rkApp.SetValue("AppName", startPath);

This is MainWindow.xaml

<Controls:MetroWindow x:Class="AppName.MainWindow"
IgnoreTaskbarOnMaximize="True" ShowTitleBar="False" WindowStyle="None" WindowState="Maximized">
...
</Controls:MetroWindow>
lahjaton_j
  • 805
  • 7
  • 13

4 Answers4

2

Take a look at Kiosk Mode for Windows 10.

From Set up a device for anyone to use (kiosk mode):

A single-use device is easy to set up in Windows 10 for desktop editions (Pro, Enterprise, and Education). For a kiosk device to run a Universal Windows app, use the assigned access feature. For a kiosk device (Windows 10 Enterprise or Education) to run a Classic Windows application, use Shell Launcher to set a custom user interface as the shell.

From Assigned access (Industry 8.1):

Administrators can use assigned access to restrict a user account to access a single application. You can use assigned access to set up single-function devices, such as restaurant menus or displays at trade shows.

The following table identifies the type of application that can be used on each Windows 10 edition to create a kiosk device.

enter image description here

A Universal Windows app is built on the Universal Windows Platform (UWP), which was first introduced in Windows 8 as the Windows Runtime. A Classic Windows application uses the Classic Windows Platform (CWP) (e.g., COM, Win32, WPF, WinForms, etc.) and is typically launched using an .EXE or .DLL file.

Black Frog
  • 11,595
  • 1
  • 35
  • 66
  • I am aware of this, but thanks for the good overview for other users seeking the answer. Assigned access is not an option since I have a Classic windows app and Enterprise is not available. I hope there is a simpler way than Shell Launcher, but I might have to look into it. – lahjaton_j Oct 13 '16 at 06:31
1

You can do this in the MainWindow.xaml.cs by adding a windowstate of maximized.

public MainWindow()
{
    InitializeComponent();
    this.WindowState = WindowState.Maximized;
}
Kyle Hancock
  • 132
  • 8
1

The solution (hack) was to open any other window (e.g. powershell) on startup using Task Scheduler, and after another window is open, we can call Alt+Tab in a powershell script using.

[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[System.Windows.Forms.SendKeys]::SendWait("%{TAB}")
lahjaton_j
  • 805
  • 7
  • 13
0

Set the Window state in the ContentRendered event handler:

protected override void OnStartup(StartupEventArgs e)
{  
    Application.Current.MainWindow.ContentRendered += (s, a) => 
        Application.Current.MainWindow.WindowState = WindowState.Maximized;

}
E-Bat
  • 4,792
  • 1
  • 33
  • 58
  • The problem is that WindowState already is Maximized, but Windows somehow decides not to view the program. Perhaps they disabled this on pupose. – lahjaton_j Oct 13 '16 at 06:50
  • So the issue is not about maximizing but instead your main window is hidden? – E-Bat Oct 13 '16 at 14:06
  • On startup, Windows shows only the start screen, even if the windowstate is maximized. On other occasions it works just fine. – lahjaton_j Oct 14 '16 at 05:25