TitleBar.IsBackButtonVisible Propiedad

Definición

Obtiene o establece un valor que indica si se muestra el botón para navegar hacia atrás.

public:
 property bool IsBackButtonVisible { bool get(); void set(bool value); };
/// [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")]
/// [get: Microsoft.UI.Xaml.CustomAttributes.MUXPropertyDefaultValue(value="false")]
/// [set: Microsoft.UI.Xaml.CustomAttributes.MUXPropertyDefaultValue(value="false")]
bool IsBackButtonVisible();

void IsBackButtonVisible(bool value);
public bool IsBackButtonVisible { [Microsoft.UI.Xaml.CustomAttributes.MUXPropertyDefaultValue(value="false")] get; [Microsoft.UI.Xaml.CustomAttributes.MUXPropertyDefaultValue(value="false")] set; }
[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

Valor de propiedad

Boolean

bool

true si se muestra el botón para navegar hacia atrás; de lo contrario, false. El valor predeterminado es false.

Atributos
Microsoft.UI.Xaml.CustomAttributes.MUXPropertyDefaultValueAttribute

Ejemplos

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

Comentarios

Al usar el control TitleBar con un control NavigationView , debe reemplazar el botón Atrás de la vista de navegación por el botón Atrás de la barra de título.

Le recomendamos que haga lo siguiente:

  • Oculte el botón Atrás en el NavigationView control. <NavigationView IsBackButtonVisible="Collapsed">
  • Muestra el botón Atrás en el TitleBar control. <TitleBar IsBackButtonVisible="True">
  • Controle el evento TitleBar.BackRequested para volver a navegar.

Se aplica a

Consulte también

  • BackRequested
  • <xref:Microsoft.UI.Xaml.Controls.TitleBar.IsBackButtonEnabled+%5bNavigationView.IsBackButtonVisible%5d(%2fwindows%2fwindows-app-sdk%2fapi%2fwinrt%2fmicrosoft.ui.xaml.controls.navigationview.isbackbuttonvisible)>