TitleBar.IsBackButtonVisible Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets a value that indicates whether the button to navigate back is shown.
public:
property bool IsBackButtonVisible { bool get(); void set(bool value); };
/// [Microsoft.UI.Xaml.CustomAttributes.MUXPropertyDefaultValue(value="false")]
/// [get: Microsoft.UI.Xaml.CustomAttributes.MUXPropertyDefaultValue(value="false")]
/// [set: Microsoft.UI.Xaml.CustomAttributes.MUXPropertyDefaultValue(value="false")]
bool IsBackButtonVisible();
void IsBackButtonVisible(bool value);
[Microsoft.UI.Xaml.CustomAttributes.MUXPropertyDefaultValue(value="false")]
public bool IsBackButtonVisible { [Microsoft.UI.Xaml.CustomAttributes.MUXPropertyDefaultValue(value="false")] get; [Microsoft.UI.Xaml.CustomAttributes.MUXPropertyDefaultValue(value="false")] set; }
var boolean = titleBar.isBackButtonVisible;
titleBar.isBackButtonVisible = boolean;
Public Property IsBackButtonVisible As Boolean
Property Value
bool
true
if the button to navigate back is shown; otherwise, false
. The default is false
.
- Attributes
-
Microsoft.UI.Xaml.CustomAttributes.MUXPropertyDefaultValueAttribute
Examples
<!-- MainWindow.xaml -->
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TitleBar Title="My App"
IsBackButtonVisible="True"
IsBackButtonEnabled="{x:Bind RootFrame.CanGoBack, Mode=OneWay}"
BackRequested="TitleBar_BackRequested">
</TitleBar>
<NavigationView x:Name="RootNavigationView" Grid.Row="1"
IsBackButtonVisible="Collapsed">
<Frame x:Name="RootFrame" />
</NavigationView>
</Grid>
// MainWindow.xaml.cs
private void TitleBar_BackRequested(TitleBar sender, object args)
{
if (RootFrame.CanGoBack)
{
RootFrame.GoBack();
}
}
Remarks
When you use the TitleBar control with a NavigationView control, you should replace the navigation view's back button with the title bar's back button.
We recommend that you:
- Hide the back button in the
NavigationView
control.<NavigationView IsBackButtonVisible="Collapsed">
- Show the back button in the
TitleBar
control.<TitleBar IsBackButtonVisible="True">
- Handle the TitleBar.BackRequested event to navigate back.
Applies to
See also
- BackRequested
- <xref:Microsoft.UI.Xaml.Controls.TitleBar.IsBackButtonEnabled+%5bNavigationView.IsBackButtonVisible%5d(%2fwindows%2fwindows-app-sdk%2fapi%2fwinrt%2fmicrosoft.ui.xaml.controls.navigationview.isbackbuttonvisible)>