Hello @BitSmithy ,
Welcome to Microsoft Q&A!
Here is an example of using a custom title bar.
It is recommended to use the system's button to exit the full screen mode, the button in this sample will be hidden when full screen.
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="32"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid x:Name="AppTitleBar" Background="Transparent">
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="LeftPaddingColumn" Width="0"/>
<ColumnDefinition/>
<ColumnDefinition x:Name="RightPaddingColumn" Width="0"/>
</Grid.ColumnDefinitions>
</Grid>
<StackPanel Orientation="Horizontal"
VerticalAlignment="Center"
HorizontalAlignment="Right"
Height="32"
Grid.Column="0">
<Button x:Name="fullScreenbtn" Content="FullScreen" Click="Button_Click" Width="90"/>
<Rectangle Width="140" Height="32"/>
</StackPanel>
</Grid>
public MainPage()
{
this.InitializeComponent();
var coreTitleBar = CoreApplication.GetCurrentView().TitleBar;
coreTitleBar.ExtendViewIntoTitleBar = true;
this.SizeChanged += MainPage_SizeChanged;
// Set XAML element as a drag region.
Window.Current.SetTitleBar(AppTitleBar);
}
private void MainPage_SizeChanged(object sender, SizeChangedEventArgs e)
{
var view = ApplicationView.GetForCurrentView();
if (view.IsFullScreenMode)
{
fullScreenbtn.Visibility = Visibility.Collapsed;
}
else
{
fullScreenbtn.Visibility = Visibility.Visible;
}
}
private void Button_Click(object sender, RoutedEventArgs e)
{
var view = ApplicationView.GetForCurrentView();
if (view.IsFullScreenMode)
{
view.ExitFullScreenMode();
ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.Auto;
fullScreenbtn.Visibility = Visibility.Visible;
}
else
{
if (view.TryEnterFullScreenMode())
{
ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.FullScreen;
fullScreenbtn.Visibility= Visibility.Collapsed;
}
}
}
Thank you.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.