Skip to content

docs(NavigationXaml): Improving xaml navigation Guide, seperate between Mvvm and Mvux - #2742

Open
DevTKSS wants to merge 12 commits into
unoplatform:mainfrom
DevTKSS:mvux-navigation-DI
Open

DevTKSS wants to merge 12 commits into
unoplatform:mainfrom
DevTKSS:mvux-navigation-DI

Conversation

@DevTKSS

@DevTKSS DevTKSS commented Apr 27, 2025

Copy link
Copy Markdown
Contributor

GitHub Issue (If applicable): closes #

PR Type

What kind of change does this PR introduce?

  • Documentation content changes

What is the current behavior?

Mvvm specific guide, but when Mvux should be used, we have a slightly different syntax (...Model instead of ...ViewModel) and the Model could get assumed to be a class instead of a record.
No visual content beside the setup intro

What is the new behavior?

  • Added Mvvm/Mvux specific content by seperation with Dependant Tabs
  • Mvux visual content added
  • Added TODO to the Navigation by NavigationView which should get improved, with Only-Pages Content Sample, while its currently Heading this but not really explaining.

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs
  • Docs have been added/updated which fit documentation template. (for bug fixes / features)
  • Unit Tests and/or UI Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Wasm UI Tests are not showing unexpected any differences. Validate PR Screenshots Compare Test Run results.
  • Contains NO breaking changes
  • Updated the Release Notes
  • Associated with an issue (GitHub or internal)

Other information

Internal Issue (If applicable):

@DevTKSS
DevTKSS force-pushed the mvux-navigation-DI branch from 05c622f to f2ec5cb Compare June 28, 2025 21:11
@DevTKSS

DevTKSS commented Jun 28, 2025

Copy link
Copy Markdown
Contributor Author

@kazo0 did you/Team see this PR?
Updated it just now. As the current Use NavigationView Guide of the Navigation Extension docs has been, and I would still say it is for a beginner, very complicated to understand and follow this up with the nested Grid Regions and so on. Of course, in cases, where we really want those regions on the same Page, that is a way to do it, but for getting a start point with navigation in a NavigationView, this is not the best way to do learn.

As I created for this need case the YouTube tutorial (currently only German localized but it has Transcripts for automatic Subtitles) I would have also some sourcecode I could use for this as its much simpler than the current approach.
e.g. this is the latest WIP version as I am adding the appropriate docs and Readme to it currently, also in English.
(the current project files are in same directory as the linked file just in case you want to take a Look on how this sample guide used code would look like I think this would may improve the current one...

@DevTKSS DevTKSS changed the title docs(NavigationXaml): Add tabbed content seperating the xaml navigation Guide between Mvvm and Mvux docs(NavigationXaml): Improving xaml navigation Guide, seperate between Mvvm and Mvux Jun 28, 2025
@DevTKSS

DevTKSS commented Jun 30, 2025

Copy link
Copy Markdown
Contributor Author

@kazo0 what do you say to this latest commits? for a beginner most of the "Advanced" docs for this are more "overloaded" as they are all utilizing the same sample apps solution which is with all of the nested areas (not speaking of routes in general!) quickly overwelming the reader. Its of course good to have one tutorial telling us, how we can set up a navigation with areas in one content like a grid with two rows etc. but its kind of ALL are like this, which makes it really hard to understand whats the endresult.

also, the source code is (was last time I tryed to look it up beginning with it) not matching the tutorial, which disables the reader to make a local clone of the sample and take a look for things that had been left out or not well described.
I think, to all of the xaml methods we can use, there should not only be a complex sample, than also one thats short and clear to follow it up.

Copilot AI review requested due to automatic review settings July 27, 2025 14:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR improves the XAML navigation documentation by separating MVVM and MVUX approaches with tabbed content, adds visual guides for MVUX, and enhances the NavigationView documentation with additional context and TODO notes for future improvements.

Key Changes:

  • Separated MVVM and MVUX specific guidance using dependent tabs throughout the navigation documentation
  • Added visual content and step-by-step screenshots for MVUX approach
  • Enhanced NavigationView documentation with better explanations and examples

Reviewed Changes

Copilot reviewed 11 out of 15 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
doc/Learn/includes/mvux-approach.md New include file defining MVUX approach note for documentation
doc/Learn/Navigation/includes/register-routes-mvvm.md MVVM-specific route registration code example
doc/Learn/Navigation/includes/register-routes-mvux.md MVUX-specific route registration code example using Model instead of ViewModel
doc/Learn/Navigation/includes/navigation-widgets-inline.md Shared widget navigation example code
doc/Learn/Navigation/includes/navigation-showing-widgets-inline.md Widget display example for navigation data
doc/Learn/Navigation/includes/navigation-data-inline.md Widget record definition for navigation examples
doc/Learn/Navigation/includes/navigate-xaml-request.md Common navigation request explanation
doc/Learn/Navigation/HowTo-NavigateInXAML.md Main navigation guide with MVVM/MVUX tabs and NavigationView content
doc/Learn/Navigation/HowTo-NavigateBetweenPages.md Updated description and fixed typo
doc/Learn/Navigation/Advanced/HowTo-UseNavigationView.md Enhanced NavigationView guide with better explanations and TODO note
doc/Learn/Navigation/Advanced/HowTo-AdvancedPageNavigation.md Converted sections to use tabbed format for consistency

@DevTKSS

DevTKSS commented Jul 28, 2025

Copy link
Copy Markdown
Contributor Author

@mtmattei you mentioned to improve the mvux - Navigation docs last week, would you like to check if you have improvements to be done here?

</ListView.ItemTemplate>
</ListView>
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kazo0 Thanks for pointing to the existing docs.
They do cover the basics, but the gap I’m highlighting is very real — and showed up again in this recent Discord question

The user struggled with the same unclear aspects I encountered myself when learning Extensions Navigation with NavigationView. He even progressed further than I did before I ended up digging through the Samples source to understand how the system behaves. 😄
And as side note, he seems to also face HR problems with Navigation, where the HR Engine stated it would have been applyied but he stated it was not changing anything. Maybe the team could check with him, if it works now?
https://discord.com/channels/1182775715242967050/1182776377955602632/1445074184714846298


Region.Navigator confusion

The user also assumed Extensions Navigation supports a Frame-style navigator and tried:

uen:Region.Navigator="FrameNavigator"

This is completely understandable because the documentation lists the property but only documents a single valid value:

Since the repository contains additional navigator implementations (e.g. FrameNavigator.cs, ControlNavigator.cs), it is natural to assume that other navigator names might be usable not just via Qualifiers.


Missing example: NavigationView + Regions + separate pages(file seperated) in NavigationView.Content

The current documentation presents navigation concepts only in isolation:

  • imperative navigation
  • Visibility-based region navigation
  • nested ContentControl regions
  • NavigationView examples without page separation

What’s missing is the combined, real-world scenario:

NavigationView + uen:Region.* + actual XAML pages

This is also the layout most developers instinctively expect, especially since Uno templates themselves use a separated-page structure. Without such an example, beginners cannot easily understand how the building blocks fit together.

This is why I suggested adding a simplified introductory step before repeating the SPA-style Visibility layout again:

https://github.com/unoplatform/uno.extensions/pull/2742/files#diff-f5237c01ad56bca7683123704d9e49cb9d7394140b7908b37f769808b4af9b15R219-R223

### [MVVM Setup](#tab/mvvm)

- Add a new `Page` to navigate to, `SamplePage.xaml`
[!include [getting-help](../includes/mvvm-approach.md)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I'm seeing why we need to separate between MVUX and MVVM Toolkit here. The syntax should be almost identical, shouldn't it? In both MVUX and MVVM we can just have a public partial class SampleViewModel

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is almoast identical, which is why I would suggest to use the includes for the parts that are same.
But no, honestly from my POV, as I freshly started with Uno, every guide that was giving me a Mvux separated tab, I was so greatfull, because it allowed me to really see a validated approach and not leaving me hoping the compiler will not again hate me and make me fail.

Our Getting Started guides are meant for exactly this consumers, for those who do not know about the specifics that more expirienced Developers are meanwhile doing automatically. E.g. the simple public partial record instead of just leaving the internal class definition that can be used for Mvvm.
By the way, while the UnoFeatures are allowing Mvvm we do miss this topic completly in the docs, assuming them to know everything about it or where to look for it.
Just to give you an understandable example:

Uno Templated Mvvm based app MainViewModel:

public partial class MainViewModel : ObservableObject // <-- see "class" used !
{
    private INavigator _navigator; // <-- should be readonly

    [ObservableProperty]
    private string? name;

    public MainViewModel(
        INavigator navigator)
    {
        _navigator = navigator;
        GoToSecond = new AsyncRelayCommand(GoToSecondView);
    }

    public ICommand GoToSecond { get; }

    private async Task GoToSecondView()
    {
        await _navigator.NavigateViewModelAsync<SecondViewModel>(this, data: new Entity(Name!));
    }
}

What we even should get for complete Mvvm usage:

public partial class DashboardViewModel : ObservableObject // <-- same here: see "class" used !
{
    private readonly INavigator _navigator;

    [ObservableProperty]
    [NotifyCanExecuteChangedFor(nameof(NavigateSecondAsyncCommand))] // <-- missing
    private string? name;

    public DashboardViewModel(INavigator navigator)
    {
        _navigator = navigator;
        NavigateSecondAsyncCommand = new AsyncRelayCommand(NavigateSecondAsync);
    }

    public IAsyncRelayCommand NavigateSecondAsyncCommand { get; }

    [RelayCommand(CanExecute = nameof(CanExecuteNavigateSecondAsync))] // <-- missing
    private async Task NavigateSecondAsync()
    {
        await _navigator.NavigateViewModelAsync<SecondViewModel>(this, data: new Entity(Name!));
    }

    private bool CanExecuteNavigateSecondAsync() // <-- (complete method) missing
    {
        return !string.IsNullOrWhiteSpace(Name);
    }
}

And now compare this to what we are getting with Mvux:

public partial record MainModel // <-- see "record" used !
{
    private INavigator _navigator; // <-- also schould be readonly !

    public DashboardModel(INavigator navigator)
    {
        _navigator = navigator;
        Title = "Dashboard"; // sample used Toolkit, not sure if this is included without it
    }

    public string? Title { get; }

    public IState<string> Name => State<string>.Value(this, () => string.Empty);

    public async Task NavigateSecondAsync()
    {
        var name = await Name;
        await _navigator.NavigateViewModelAsync<SecondModel>(this, data: new Entity(name!));
    }

}

So, no, even if it looks like duplication, as User it helps in those getting started and even more important a getting help section tabbed content to every differencing guides otherwhise you could assume its same, but as soon as we are connecting INavigation with parameter provided Arguments and not just a "Button.Command" without a Parameter, that potentially causes problems on user side, which we should target to prevent.

This would enhance the Docs independant of the extension its about, and make Mvux accessible to be used all over out uno apps. It is simply not the case that choosing Mvux you will only have it in e.g. MainModel, then instead have it in every other Model or even Service maybe (which nobody talks about if we maybe should do them also as record or when we should want to have class!) which potentially and realistically can use Http or anything else then no service.
So maybe see Navigation here as first example of what we should want to have the whole Extensions docs set up like -> Our User can choose Mvvm or Mvux? Then we should provide guidiance for implementing things in our VM or Model with both! 👍

because we (should) want them to be successfull and recommend it as efficiency providing, understandable and fluentlessly integrateable feature in our apps 🚀


### 2. Navigation.Data

#### [MVVM](#tab/mvvm/NavigationData)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I'm seeing why we need to separate between MVUX and MVVM Toolkit here. The syntax should be almost identical, shouldn't it?

Just need to define a view model that has a constructor parameter for the data

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants