locked
Fullscreen apps. RRS feed

  • Question

  • Sorry but a but of a noob question(only starting C# with UWP. Came from VB and Win32).

    How can I get my app to enter full screen by either:

    • Tapping a button.
    • Pressing a key on the keyboard.
    • And/or having the "Full Screen" button on the app bar.

    Cheers!

    For the record, this is to build a media centre shell for a HTPC.


    David98xp

    Wednesday, October 14, 2015 4:13 AM

Answers

  • Hi David98xp,

    You can use ApplicationView.TryEnterFullScreenMode method to get your app to enter full screen. For example, in your button click event using following code

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        var view = ApplicationView.GetForCurrentView();
        if (view.IsFullScreenMode)
        {
            view.ExitFullScreenMode();
        }
        else
        {
            view.TryEnterFullScreenMode();
        }
    }
    

    If you want to control this by pressing a key on keyboard, you can refer to Shortcut keys example.

    And to use it in the app bar, you can refer to following sample

    <Page.BottomAppBar>
        <CommandBar>
            <AppBarButton Icon="FullScreen" Label="Full Screen" Click="Button_Click"/>
        </CommandBar>
    </Page.BottomAppBar>

    For more information, please see CommandBar class.

    Hope this helps.

    Regards,

    Jay 

    • Marked as answer by David98xp Wednesday, October 14, 2015 8:06 AM
    Wednesday, October 14, 2015 6:31 AM

All replies

  • To go fullscreen, just call ApplicationView.GetForCurrentView().TryEnterFullScreenMode().

    For instance, from a button:

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        ApplicationView.GetForCurrentView().TryEnterFullScreenMode();
    }
    

    Wednesday, October 14, 2015 6:11 AM
  • Hi David98xp,

    You can use ApplicationView.TryEnterFullScreenMode method to get your app to enter full screen. For example, in your button click event using following code

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        var view = ApplicationView.GetForCurrentView();
        if (view.IsFullScreenMode)
        {
            view.ExitFullScreenMode();
        }
        else
        {
            view.TryEnterFullScreenMode();
        }
    }
    

    If you want to control this by pressing a key on keyboard, you can refer to Shortcut keys example.

    And to use it in the app bar, you can refer to following sample

    <Page.BottomAppBar>
        <CommandBar>
            <AppBarButton Icon="FullScreen" Label="Full Screen" Click="Button_Click"/>
        </CommandBar>
    </Page.BottomAppBar>

    For more information, please see CommandBar class.

    Hope this helps.

    Regards,

    Jay 

    • Marked as answer by David98xp Wednesday, October 14, 2015 8:06 AM
    Wednesday, October 14, 2015 6:31 AM
  • Thanks!

    David98xp

    Wednesday, October 14, 2015 8:05 AM
  • Thank you! That was very helpful.

    I apologise but instead of the AppBar I meant the app's "Title bar"


    David98xp

    Wednesday, October 14, 2015 8:06 AM
  • Hi David98xp,

    To set a full screen button in Title bar, you can use CoreApplicationViewTitleBar.ExtendViewIntoTitleBar property and Window.SetTitleBar method to custom your title bar. Rember first set the CoreApplicationViewTitleBar.ExtendViewIntoTitleBar property to true in order to hide the default system title bar. If you call this method without first setting ExtendViewIntoTitleBar, it has no effect. Please notice the Remarks section of Window.SetTitleBar method and also refer to this article to implement your own title bar.

    Hope this helps.

    Regards,

    Jay

    Wednesday, October 14, 2015 4:30 PM