lepoco / wpfui

WPF UI provides the Fluent experience in your known and loved WPF framework. Intuitive design, themes, navigation and new immersive controls. All natively and effortlessly.
https://wpfui.lepo.co
MIT License
7.51k stars 727 forks source link

No way to customize the NavigationView breadcrumbs (NavigationViewBreadcrumbItem) #889

Open alxnik opened 9 months ago

alxnik commented 9 months ago

Is your feature request related to a problem? Please describe

The NavigationView binds to a BreadcrumbBar to show the main navigation in the header. However there is a customization of the BreadcrumbBarItem named NavigationViewBreadcrumbItem which is used to show navigation items. This class in internal and thus, it cannot be customized.

Describe the solution you'd like

Either make NavigationViewBreadcrumbItem public or allow for the changing of its typography some other way.

Describe alternatives you've considered

No response

Additional context

No response

Dealman commented 8 months ago

Can confirm that this is still an issue, even in WPF UI 13.0.0. Can't find a way to update the BreadcrumbBar title when you manually navigate to a different page.

Of course, one can add their own title to mimic the behaviour. But this seems like an oversight.

Edit:

I had some looking around how things work and I believe you and I may be approaching this the wrong way around.

Take this example;

[ObservableProperty]
private ObservableCollection<object> _menuItems = new()
{
    new NavigationViewItem()
    {
        Content = "Home",
        Icon = new SymbolIcon { Symbol = SymbolRegular.Home24 },
        TargetPageType = typeof(Views.Pages.DashboardPage)
    },
    new NavigationViewItem()
    {
        Content = "Data",
        Icon = new SymbolIcon { Symbol = SymbolRegular.DataHistogram24 },
        TargetPageType = typeof(Views.Pages.DataPage)
    },
    new NavigationViewItem()
    {
        Content = "Not Visible Test",
        Icon = new SymbolIcon { Symbol = SymbolRegular.DataHistogram24 },
        TargetPageType = typeof(Views.Pages.MyCustomPge),
        Visibility = Visibility.Collapsed
    },
    new NavigationViewItem()
    {
        Content = "Visible Test",
        Icon = new SymbolIcon { Symbol = SymbolRegular.DataHistogram24 },
        TargetPageType = typeof(Views.Pages.MyCustomPge)
    }
};

Here I add two new pages, one of which has its visibility set to Collapsed. Thus it won't actually display in the menu nor take up room. And then you can navigate to this page either using the NavigationView itself or manually using INavigationService and the title will be updated as expected.

For example, I navigate like this;

_navigationService.NavigateWithHierarchy(typeof(MyCustomPge));

image That said, I honestly do believe this does feel a bit unintuitive. A simple method to programmatically set/override this would be rather convenient and reduce bloat.

zbellerose commented 6 months ago

I'm not 100% sure if this is what you are asking for, but you can use ui:NavigationView.HeaderContent="{Binding ViewModel.HeaderContent}" to programmatically set this value. This would be set in the page XAML

<Page
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:local="clr-namespace:x.x.x"
      xmlns:controls="clr-namespace:x.x"
      xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
      ui:NavigationView.HeaderContent="{Binding ViewModel.HeaderContent}" <!--Shown Here-->
      ui:Design.Background="{DynamicResource ApplicationBackgroundBrush}" 
      d:DesignWidth="750"
      d:DesignHeight="555">

There are some limitations I've found for this. Once you navigate to the screen you can't update the value again. So if I happen to want to change the header without navigating to the screen again, I don't seem to see a way too at the moment.

But, I can change it before I navigate to the screen. So that has been somewhat helpful.

Edit:

I found a very "Hack" way of updating it by simply navigating to the previous page and then navigating back.

 _ = _navigationService.GoBack();
 _ = _navigationService.NavigateWithHierarchy(typeof(pageTypeHere));
SilkageNet commented 3 months ago

image

ui:NavigationView.HeaderContent Binding not working