Skip to content

Junevy/SimpleNavigation

Repository files navigation

Introduction

An ultra-lightweight navigation framework that makes implementing navigation a breeze!

Use

  1. Using the SimpleNavigation.dll
  2. Register and Build the DI container:
        public void InitialProvider()
        {
            var container = new ServiceCollection();

            container.AddTransient<MainWindow>();
            container.AddSingleton<MainWindowViewModel>();
            container.AddTransient<TestWindow>();
            container.AddSingleton<TestViewModel>();

            container.AddSingleton( (p) => new TestPage() { ShowsNavigationUI = false});

            container.AddSingleton<IDialogService, DialogService>();
            container.AddSingleton<IPageService, PageService>();

            container.AddSingleton<IServiceProvider, ServiceProvider>();
            Provider = container.BuildServiceProvider();
        }
  1. Register Region and binding Command:
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition MaxHeight="20" />
            <RowDefinition />
        </Grid.RowDefinitions>

        <Menu Grid.Row="0">
            <MenuItem Header="Test">
                <MenuItem Header="Test">
                    <MenuItem Command="{Binding OpenWindowCommand}" Header="test1" />
                    <MenuItem Command="{Binding RegionTestCommand}" Header="test1" />
                </MenuItem>

                <MenuItem Header="demo">
                    <MenuItem Header="demo1" />
                </MenuItem>
            </MenuItem>
        </Menu>

        <Frame Grid.Row="1" sn:RegionService.RegionName="Main" />

    </Grid>
  1. Navigate to other Page or show Dialog:
        [RelayCommand]
        public void OpenWindow()
        {
            var param = new DialogParameters("key", "value");
            var result = dialogService.ShowDialog<TestWindow>(param);
        }

        [RelayCommand]
        public void RegionTest()
        {
            pageService.Navigate<TestPage>("Main");
        }
  1. The Result:
image

About

A simple, extremely lightweight WPF navigation framework designed to work with Community.ToolKit and DependencyInjection.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages