Ghost1372

everything can be handy

NavigationPageMappingsGenerator

Use this generator to create a page-mapping dictionary class for JsonNavigationService, and configure it by calling
NavService.Initialize(NavView, NavFrame, NavigationPageMappings.PageDictionary).

This generator reads the JSON file and extracts each UniqueId along with its corresponding page type.

How To Use it?

Just add an AdditionalFiles entry to your .csproj.

1
2
3
<ItemGroup>
<AdditionalFiles Include="Assets\NavViewMenu\AppData.json" />
</ItemGroup>

Namespace

You can define your own namespace by adding a property to a PropertyGroup.

1
2
3
<PropertyGroup>
<NavigationMappingsNamespace>MyNavigationMappingsNamespace</NavigationMappingsNamespace>
</PropertyGroup>

Result

The result is a mapping dictionary similar to the following:

1
2
3
4
5
6
7
8
9
public partial class NavigationPageMappings
{
public static Dictionary<string, Type> PageDictionary { get; } = new Dictionary<string, Type>
{
{"DevWinUIGallery.Views.HomeLandingPage", typeof(DevWinUIGallery.Views.HomeLandingPage)},
{"DevWinUIGallery.Views.ColorAnalyzerPage", typeof(DevWinUIGallery.Views.ColorAnalyzerPage)},
{"DevWinUIGallery.Views.MenuFlyoutSecondaryMenuPage", typeof(DevWinUIGallery.Views.MenuFlyoutSecondaryMenuPage)},
}
}
0%