// This Source Code Form is subject to the terms of the MIT License. // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. using TextViewModel = WPFluent.Gallery.ViewModels.Pages.TextViewModel; namespace WPFluent.Gallery.Views; public partial class TextPage : INavigableView { private readonly INavigationService _navigationService; public TextViewModel ViewModel { get; } public TextPage(TextViewModel viewModel, INavigationService navigationService) { ViewModel = viewModel; DataContext = this; _navigationService = navigationService; InitializeComponent(); Loaded += HandleLoaded; Unloaded += HandleUnloaded; } private void HandleLoaded(object sender, RoutedEventArgs e) { INavigationView? navigationControl = _navigationService.GetNavigationControl(); if ( navigationControl?.BreadcrumbBar != null && navigationControl.BreadcrumbBar.Visibility != Visibility.Collapsed ) { navigationControl.BreadcrumbBar.SetCurrentValue(VisibilityProperty, Visibility.Collapsed); } } private void HandleUnloaded(object sender, RoutedEventArgs e) { INavigationView? navigationControl = _navigationService.GetNavigationControl(); if ( navigationControl?.BreadcrumbBar != null && navigationControl.BreadcrumbBar.Visibility != Visibility.Visible ) { navigationControl.BreadcrumbBar.SetCurrentValue(VisibilityProperty, Visibility.Visible); } Loaded -= HandleLoaded; Unloaded -= HandleUnloaded; } }