diff --git a/.github/workflows/dotnet-format.yml b/.github/workflows/dotnet-format.yml
index b25ada1d9d..60c2dce23d 100644
--- a/.github/workflows/dotnet-format.yml
+++ b/.github/workflows/dotnet-format.yml
@@ -21,10 +21,10 @@ jobs:
with:
ref: ${{ github.head_ref }}
- - name: Run dotnet format
- id: format
- uses: jfversluis/dotnet-format@v1.0.9
- with:
- repo-token: ${{ secrets.GITHUB_TOKEN }}
- only-changed-files: true
- workspace: "PrismLibrary.sln"
+ # - name: Run dotnet format
+ # id: format
+ # uses: jfversluis/dotnet-format@v1.0.9
+ # with:
+ # repo-token: ${{ secrets.GITHUB_TOKEN }}
+ # only-changed-files: false
+ # workspace: "PrismLibrary.sln"
diff --git a/Directory.Build.props b/Directory.Build.props
index 46aa7f4b4d..9dc72fea5a 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -95,6 +95,11 @@
+
+
+
+
+
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 2ea1b222d7..c1b4283eda 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -7,7 +7,6 @@
-
@@ -15,15 +14,15 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
@@ -31,19 +30,19 @@
-
+
-
-
-
+
+
+
-
+
-
-
+
+
diff --git a/e2e/Forms/src/HelloRegions/RegionDemoModule.cs b/e2e/Forms/src/HelloRegions/RegionDemoModule.cs
index 6faa12e02b..f946d18707 100644
--- a/e2e/Forms/src/HelloRegions/RegionDemoModule.cs
+++ b/e2e/Forms/src/HelloRegions/RegionDemoModule.cs
@@ -1,4 +1,3 @@
-using System;
using HelloRegions.ViewModels;
using HelloRegions.Views;
using Prism.Ioc;
diff --git a/e2e/Forms/src/HelloRegions/ViewModels/CarouselDemoRegionViewModel.cs b/e2e/Forms/src/HelloRegions/ViewModels/CarouselDemoRegionViewModel.cs
index c81144a1ff..73286f9d2c 100644
--- a/e2e/Forms/src/HelloRegions/ViewModels/CarouselDemoRegionViewModel.cs
+++ b/e2e/Forms/src/HelloRegions/ViewModels/CarouselDemoRegionViewModel.cs
@@ -1,4 +1,4 @@
-using Prism.Regions;
+using Prism.Navigation.Regions;
namespace HelloRegions.ViewModels
{
diff --git a/e2e/Forms/src/HelloRegions/ViewModels/CollectionViewDemoRegionViewModel.cs b/e2e/Forms/src/HelloRegions/ViewModels/CollectionViewDemoRegionViewModel.cs
index 0418ed476e..16e23acee9 100644
--- a/e2e/Forms/src/HelloRegions/ViewModels/CollectionViewDemoRegionViewModel.cs
+++ b/e2e/Forms/src/HelloRegions/ViewModels/CollectionViewDemoRegionViewModel.cs
@@ -1,4 +1,4 @@
-using Prism.Regions;
+using Prism.Navigation.Regions;
namespace HelloRegions.ViewModels
{
diff --git a/e2e/Forms/src/HelloRegions/ViewModels/ContentViewDemoRegionViewModel.cs b/e2e/Forms/src/HelloRegions/ViewModels/ContentViewDemoRegionViewModel.cs
index 5b171ec8fc..ab4266b9aa 100644
--- a/e2e/Forms/src/HelloRegions/ViewModels/ContentViewDemoRegionViewModel.cs
+++ b/e2e/Forms/src/HelloRegions/ViewModels/ContentViewDemoRegionViewModel.cs
@@ -1,4 +1,4 @@
-using Prism.Regions;
+using Prism.Navigation.Regions;
namespace HelloRegions.ViewModels
{
diff --git a/e2e/Forms/src/HelloRegions/ViewModels/FlexLayoutDemoRegionViewModel.cs b/e2e/Forms/src/HelloRegions/ViewModels/FlexLayoutDemoRegionViewModel.cs
index 91c2c0e6f6..ff81107151 100644
--- a/e2e/Forms/src/HelloRegions/ViewModels/FlexLayoutDemoRegionViewModel.cs
+++ b/e2e/Forms/src/HelloRegions/ViewModels/FlexLayoutDemoRegionViewModel.cs
@@ -1,4 +1,4 @@
-using Prism.Regions;
+using Prism.Navigation.Regions;
namespace HelloRegions.ViewModels
{
diff --git a/e2e/Forms/src/HelloRegions/ViewModels/FrameDemoRegionViewModel.cs b/e2e/Forms/src/HelloRegions/ViewModels/FrameDemoRegionViewModel.cs
index 94bc895308..91a85f4e9a 100644
--- a/e2e/Forms/src/HelloRegions/ViewModels/FrameDemoRegionViewModel.cs
+++ b/e2e/Forms/src/HelloRegions/ViewModels/FrameDemoRegionViewModel.cs
@@ -1,4 +1,4 @@
-using Prism.Regions;
+using Prism.Navigation.Regions;
namespace HelloRegions.ViewModels
{
diff --git a/e2e/Forms/src/HelloRegions/ViewModels/RegionAViewModel.cs b/e2e/Forms/src/HelloRegions/ViewModels/RegionAViewModel.cs
index 75531b16a9..9b291c5a96 100644
--- a/e2e/Forms/src/HelloRegions/ViewModels/RegionAViewModel.cs
+++ b/e2e/Forms/src/HelloRegions/ViewModels/RegionAViewModel.cs
@@ -3,7 +3,7 @@
using System.Windows.Input;
using Prism.Commands;
using Prism.Navigation;
-using Prism.Regions.Navigation;
+using Prism.Navigation.Regions.Navigation;
namespace HelloRegions.ViewModels
{
diff --git a/e2e/Forms/src/HelloRegions/ViewModels/RegionBViewModel.cs b/e2e/Forms/src/HelloRegions/ViewModels/RegionBViewModel.cs
index 6bd547395f..8f229dba0a 100644
--- a/e2e/Forms/src/HelloRegions/ViewModels/RegionBViewModel.cs
+++ b/e2e/Forms/src/HelloRegions/ViewModels/RegionBViewModel.cs
@@ -1,4 +1,4 @@
-using Prism.Regions.Navigation;
+using Prism.Navigation.Regions.Navigation;
namespace HelloRegions.ViewModels
{
diff --git a/e2e/Forms/src/HelloRegions/ViewModels/RegionCViewModel.cs b/e2e/Forms/src/HelloRegions/ViewModels/RegionCViewModel.cs
index 220bac4ed6..102c68e3d7 100644
--- a/e2e/Forms/src/HelloRegions/ViewModels/RegionCViewModel.cs
+++ b/e2e/Forms/src/HelloRegions/ViewModels/RegionCViewModel.cs
@@ -1,4 +1,4 @@
-using Prism.Regions.Navigation;
+using Prism.Navigation.Regions.Navigation;
namespace HelloRegions.ViewModels
{
diff --git a/e2e/Forms/src/HelloRegions/ViewModels/RegionDemoBase.cs b/e2e/Forms/src/HelloRegions/ViewModels/RegionDemoBase.cs
index d0a6c21d8b..d7a606a397 100644
--- a/e2e/Forms/src/HelloRegions/ViewModels/RegionDemoBase.cs
+++ b/e2e/Forms/src/HelloRegions/ViewModels/RegionDemoBase.cs
@@ -1,9 +1,7 @@
-using System;
using Prism.Commands;
using Prism.Mvvm;
using Prism.Navigation;
-using Prism.Regions;
-using Prism.Regions.Navigation;
+using Prism.Navigation.Regions;
namespace HelloRegions.ViewModels
{
@@ -26,7 +24,7 @@ private void Navigate(string target)
_regionManager.RequestNavigate(RegionName, target, NavigationCallback);
}
- private void NavigationCallback(IRegionNavigationResult result)
+ private void NavigationCallback(NavigationResult result)
{
}
diff --git a/e2e/Forms/src/HelloRegions/ViewModels/ScrollViewDemoRegionViewModel.cs b/e2e/Forms/src/HelloRegions/ViewModels/ScrollViewDemoRegionViewModel.cs
index d22bb75c63..92499b059f 100644
--- a/e2e/Forms/src/HelloRegions/ViewModels/ScrollViewDemoRegionViewModel.cs
+++ b/e2e/Forms/src/HelloRegions/ViewModels/ScrollViewDemoRegionViewModel.cs
@@ -1,4 +1,4 @@
-using Prism.Regions;
+using Prism.Navigation.Regions;
namespace HelloRegions.ViewModels
{
diff --git a/e2e/Forms/src/HelloRegions/ViewModels/StackLayoutDemoRegionViewModel.cs b/e2e/Forms/src/HelloRegions/ViewModels/StackLayoutDemoRegionViewModel.cs
index 4faa8db136..76cf084384 100644
--- a/e2e/Forms/src/HelloRegions/ViewModels/StackLayoutDemoRegionViewModel.cs
+++ b/e2e/Forms/src/HelloRegions/ViewModels/StackLayoutDemoRegionViewModel.cs
@@ -1,4 +1,4 @@
-using Prism.Regions;
+using Prism.Navigation.Regions;
namespace HelloRegions.ViewModels
{
diff --git a/e2e/Forms/src/HelloRegions/ViewModels/ViewModelBase.cs b/e2e/Forms/src/HelloRegions/ViewModels/ViewModelBase.cs
index 442730a261..87cee7869e 100644
--- a/e2e/Forms/src/HelloRegions/ViewModels/ViewModelBase.cs
+++ b/e2e/Forms/src/HelloRegions/ViewModels/ViewModelBase.cs
@@ -1,7 +1,7 @@
using System;
using Prism.Commands;
using Prism.Mvvm;
-using Prism.Regions.Navigation;
+using Prism.Navigation.Regions;
namespace HelloRegions.ViewModels
{
@@ -38,28 +38,28 @@ public bool IsActive
set => SetProperty(ref _isActive, value, OnIsActiveChanged);
}
- private INavigationContext _context;
- private INavigationContext Context
+ private NavigationContext _context;
+ private NavigationContext Context
{
get => _context;
set => SetProperty(ref _context, value);
}
- public bool IsNavigationTarget(INavigationContext navigationContext)
+ public bool IsNavigationTarget(NavigationContext navigationContext)
{
Console.WriteLine($"{GetType().Name} IsNavigationTarget called");
var lookingFor = navigationContext.NavigatedName();
return _contextName == lookingFor;
}
- public void OnNavigatedFrom(INavigationContext navigationContext)
+ public void OnNavigatedFrom(NavigationContext navigationContext)
{
Context = navigationContext;
Console.WriteLine($"{GetType().Name} NavigatedFrom");
}
private string _contextName;
- public void OnNavigatedTo(INavigationContext navigationContext)
+ public void OnNavigatedTo(NavigationContext navigationContext)
{
Context = navigationContext;
_contextName = navigationContext.NavigatedName();
diff --git a/e2e/Maui/Directory.Build.targets b/e2e/Maui/Directory.Build.targets
index d6f56d74f7..b3e1ad3ae4 100644
--- a/e2e/Maui/Directory.Build.targets
+++ b/e2e/Maui/Directory.Build.targets
@@ -1,3 +1,4 @@
-
+
+
diff --git a/e2e/Maui/MauiRegionsModule/MauiTestRegionsModule.cs b/e2e/Maui/MauiRegionsModule/MauiTestRegionsModule.cs
index 6227b93c77..f4fb0ee8e0 100644
--- a/e2e/Maui/MauiRegionsModule/MauiTestRegionsModule.cs
+++ b/e2e/Maui/MauiRegionsModule/MauiTestRegionsModule.cs
@@ -8,7 +8,7 @@ public class MauiTestRegionsModule : IModule
public void OnInitialized(IContainerProvider containerProvider)
{
var regionManager = containerProvider.Resolve();
- regionManager.RegisterViewWithRegion("ContentRegion", "RegionViewA");
+ regionManager.RegisterViewWithRegion("ContentRegion");
}
public void RegisterTypes(IContainerRegistry containerRegistry)
@@ -23,4 +23,4 @@ public void RegisterTypes(IContainerRegistry containerRegistry)
.RegisterForRegionNavigation()
.RegisterForRegionNavigation();
}
-}
\ No newline at end of file
+}
diff --git a/e2e/Maui/MauiRegionsModule/ViewModels/RegionViewModelBase.cs b/e2e/Maui/MauiRegionsModule/ViewModels/RegionViewModelBase.cs
index b602875194..5106d33768 100644
--- a/e2e/Maui/MauiRegionsModule/ViewModels/RegionViewModelBase.cs
+++ b/e2e/Maui/MauiRegionsModule/ViewModels/RegionViewModelBase.cs
@@ -15,7 +15,7 @@ protected RegionViewModelBase(INavigationService navigationService, IPageAccesso
_pageAccessor = pageAccessor;
}
- public bool IsNavigationTarget(INavigationContext navigationContext) =>
+ public bool IsNavigationTarget(NavigationContext navigationContext) =>
navigationContext.NavigatedName() == Name;
private string? _message;
@@ -34,12 +34,12 @@ public int ViewCount
public string? PageName => _pageAccessor.Page?.GetType()?.Name;
- public void OnNavigatedFrom(INavigationContext navigationContext)
+ public void OnNavigatedFrom(NavigationContext navigationContext)
{
}
- public void OnNavigatedTo(INavigationContext navigationContext)
+ public void OnNavigatedTo(NavigationContext navigationContext)
{
if (navigationContext.Parameters.ContainsKey(nameof(Message)))
Message = navigationContext.Parameters.GetValue(nameof(Message));
diff --git a/e2e/Uno/Directory.Build.targets b/e2e/Uno/Directory.Build.targets
index b0c04079aa..dbba02f980 100644
--- a/e2e/Uno/Directory.Build.targets
+++ b/e2e/Uno/Directory.Build.targets
@@ -1,3 +1,3 @@
-
+
diff --git a/e2e/Uno/HelloWorld/Views/Shell.xaml b/e2e/Uno/HelloWorld/Views/Shell.xaml
index e428fa9c31..604bd8565b 100644
--- a/e2e/Uno/HelloWorld/Views/Shell.xaml
+++ b/e2e/Uno/HelloWorld/Views/Shell.xaml
@@ -2,7 +2,7 @@
x:Class="HelloWorld.Views.Shell"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:pr="using:Prism.Regions"
+ xmlns:pr="using:Prism.Navigation.Regions"
xmlns:pvm="using:Prism.Mvvm"
pvm:ViewModelLocator.AutowireViewModel="true"
xmlns:local="using:HelloWorld.Views"
diff --git a/e2e/Wpf/HelloWorld/ViewModels/MainWindowViewModel.cs b/e2e/Wpf/HelloWorld/ViewModels/MainWindowViewModel.cs
index 7d2d649890..85dd65a26f 100644
--- a/e2e/Wpf/HelloWorld/ViewModels/MainWindowViewModel.cs
+++ b/e2e/Wpf/HelloWorld/ViewModels/MainWindowViewModel.cs
@@ -2,7 +2,7 @@
using HelloWorld.Core;
using Prism.Commands;
using Prism.Mvvm;
-using Prism.Regions;
+using Prism.Navigation.Regions;
using Prism.Dialogs;
namespace HelloWorld.ViewModels
@@ -35,7 +35,7 @@ public MainWindowViewModel(IDialogService dialogService, IRegionManager regionMa
{
_dialogService = dialogService;
_regionManager = regionManager;
- ShowDialogCommand = new DelegateCommand(ShowDialog);
+ ShowDialogCommand = new DelegateCommand(ShowDialog);
}
private void ShowDialog()
diff --git a/src/Forms/Prism.Forms.Regions/Behaviors/RegionCleanupBehavior.cs b/src/Forms/Prism.Forms.Regions/Behaviors/RegionCleanupBehavior.cs
index 611901c603..7243c0ca66 100644
--- a/src/Forms/Prism.Forms.Regions/Behaviors/RegionCleanupBehavior.cs
+++ b/src/Forms/Prism.Forms.Regions/Behaviors/RegionCleanupBehavior.cs
@@ -1,7 +1,6 @@
using System;
using Prism.Ioc;
-using Prism.Regions;
-using Prism.Regions.Xaml;
+using Prism.Navigation.Regions;
using Xamarin.Forms;
namespace Prism.Behaviors
diff --git a/src/Forms/Prism.Forms.Regions/Common/MvvmHelpers.cs b/src/Forms/Prism.Forms.Regions/Common/MvvmHelpers.cs
index 3d7f8a5848..048ab9aba1 100644
--- a/src/Forms/Prism.Forms.Regions/Common/MvvmHelpers.cs
+++ b/src/Forms/Prism.Forms.Regions/Common/MvvmHelpers.cs
@@ -1,5 +1,5 @@
using System;
-using Prism.Regions.Navigation;
+using Prism.Navigation.Regions;
using Xamarin.Forms;
namespace Prism.Common
@@ -34,7 +34,7 @@ public static T GetImplementerFromViewOrViewModel(object view)
return null;
}
- public static bool IsNavigationTarget(object view, INavigationContext navigationContext)
+ public static bool IsNavigationTarget(object view, NavigationContext navigationContext)
{
if (view is IRegionAware viewAsRegionAware)
{
@@ -55,12 +55,12 @@ public static bool IsNavigationTarget(object view, INavigationContext navigation
return path == viewType.Name || path == viewType.FullName;
}
- public static void OnNavigatedFrom(object view, INavigationContext navigationContext)
+ public static void OnNavigatedFrom(object view, NavigationContext navigationContext)
{
ViewAndViewModelAction(view, x => x.OnNavigatedFrom(navigationContext));
}
- public static void OnNavigatedTo(object view, INavigationContext navigationContext)
+ public static void OnNavigatedTo(object view, NavigationContext navigationContext)
{
ViewAndViewModelAction(view, x => x.OnNavigatedTo(navigationContext));
}
diff --git a/src/Forms/Prism.Forms.Regions/Ioc/RegionRegistrationExtensions.cs b/src/Forms/Prism.Forms.Regions/Ioc/RegionRegistrationExtensions.cs
index eb64c8b4b6..41a219f9c4 100644
--- a/src/Forms/Prism.Forms.Regions/Ioc/RegionRegistrationExtensions.cs
+++ b/src/Forms/Prism.Forms.Regions/Ioc/RegionRegistrationExtensions.cs
@@ -1,8 +1,8 @@
-using System;
-using Prism.Regions;
-using Prism.Regions.Adapters;
-using Prism.Regions.Behaviors;
-using Prism.Regions.Navigation;
+using System;
+using Prism.Navigation.Regions;
+using Prism.Navigation.Regions.Adapters;
+using Prism.Navigation.Regions.Behaviors;
+using Prism.Navigation.Regions.Navigation;
using Xamarin.Forms;
namespace Prism.Ioc
diff --git a/src/Forms/Prism.Forms.Regions/Ioc/RegionResolverOverrides.cs b/src/Forms/Prism.Forms.Regions/Ioc/RegionResolverOverrides.cs
index a4d3577988..9ed0a5e898 100644
--- a/src/Forms/Prism.Forms.Regions/Ioc/RegionResolverOverrides.cs
+++ b/src/Forms/Prism.Forms.Regions/Ioc/RegionResolverOverrides.cs
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using Prism.Navigation;
-using Prism.Regions;
+using Prism.Navigation.Regions;
namespace Prism.Ioc
{
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Adapters/CarouselViewRegionAdapter.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Adapters/CarouselViewRegionAdapter.cs
similarity index 95%
rename from src/Forms/Prism.Forms.Regions/Regions/Adapters/CarouselViewRegionAdapter.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/Adapters/CarouselViewRegionAdapter.cs
index 0737ea9a3d..c992b4d2e4 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/Adapters/CarouselViewRegionAdapter.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Adapters/CarouselViewRegionAdapter.cs
@@ -1,18 +1,13 @@
using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using Prism.Behaviors;
using Prism.Common;
using Prism.Ioc;
-using Prism.Navigation;
using Prism.Properties;
-using Prism.Regions.Behaviors;
-using Prism.Regions.Navigation;
using Xamarin.Forms;
-namespace Prism.Regions.Adapters
+namespace Prism.Navigation.Regions.Adapters
{
///
/// Adapter that creates a new and monitors its
@@ -56,7 +51,7 @@ protected override void Adapt(IRegion region, CarouselView regionTarget)
region.ActiveViews.CollectionChanged += delegate
{
- var activeView = region.ActiveViews.FirstOrDefault();
+ var activeView = region.ActiveViews.OfType().FirstOrDefault();
regionBehavior.CurrentView = activeView;
regionTarget.CurrentItem = activeView;
};
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Adapters/CollectionViewRegionAdapter.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Adapters/CollectionViewRegionAdapter.cs
similarity index 97%
rename from src/Forms/Prism.Forms.Regions/Regions/Adapters/CollectionViewRegionAdapter.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/Adapters/CollectionViewRegionAdapter.cs
index a3a507879a..7c408181e7 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/Adapters/CollectionViewRegionAdapter.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Adapters/CollectionViewRegionAdapter.cs
@@ -1,10 +1,9 @@
using System;
using Prism.Ioc;
using Prism.Properties;
-using Prism.Regions.Behaviors;
using Xamarin.Forms;
-namespace Prism.Regions.Adapters
+namespace Prism.Navigation.Regions.Adapters
{
///
/// Adapter that creates a new and monitors its
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Adapters/ContentViewRegionAdapter.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Adapters/ContentViewRegionAdapter.cs
similarity index 98%
rename from src/Forms/Prism.Forms.Regions/Regions/Adapters/ContentViewRegionAdapter.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/Adapters/ContentViewRegionAdapter.cs
index dfe0b539db..a47e7c062c 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/Adapters/ContentViewRegionAdapter.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Adapters/ContentViewRegionAdapter.cs
@@ -3,10 +3,9 @@
using System.Linq;
using Prism.Ioc;
using Prism.Properties;
-using Prism.Regions.Behaviors;
using Xamarin.Forms;
-namespace Prism.Regions.Adapters
+namespace Prism.Navigation.Regions.Adapters
{
///
/// Adapter that creates a new and monitors its
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Adapters/LayoutViewRegionAdapter.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Adapters/LayoutViewRegionAdapter.cs
similarity index 97%
rename from src/Forms/Prism.Forms.Regions/Regions/Adapters/LayoutViewRegionAdapter.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/Adapters/LayoutViewRegionAdapter.cs
index a7fa31315d..c1bf7237ef 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/Adapters/LayoutViewRegionAdapter.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Adapters/LayoutViewRegionAdapter.cs
@@ -2,10 +2,9 @@
using System.Linq;
using Prism.Ioc;
using Prism.Properties;
-using Prism.Regions.Behaviors;
using Xamarin.Forms;
-namespace Prism.Regions.Adapters
+namespace Prism.Navigation.Regions.Adapters
{
///
/// Adapter that creates a new and monitors its
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Adapters/RegionAdapterBase.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Adapters/RegionAdapterBase.cs
similarity index 97%
rename from src/Forms/Prism.Forms.Regions/Regions/Adapters/RegionAdapterBase.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/Adapters/RegionAdapterBase.cs
index 750194d9f1..7f89095adc 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/Adapters/RegionAdapterBase.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Adapters/RegionAdapterBase.cs
@@ -1,10 +1,10 @@
using System;
using System.Globalization;
+using Prism.Navigation.Regions.Behaviors;
using Prism.Properties;
-using Prism.Regions.Behaviors;
using Xamarin.Forms;
-namespace Prism.Regions.Adapters
+namespace Prism.Navigation.Regions.Adapters
{
///
/// Base class to facilitate the creation of implementations.
@@ -55,7 +55,7 @@ public IRegion Initialize(T regionTarget, string regionName)
/// is of type .
/// When is .
/// When is not of type .
- IRegion IRegionAdapter.Initialize(VisualElement regionTarget, string regionName)
+ IRegion IRegionAdapter.Initialize(object regionTarget, string regionName)
{
return Initialize(GetCastedObject(regionTarget), regionName);
}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Adapters/RegionAdapterMappings.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Adapters/RegionAdapterMappings.cs
similarity index 99%
rename from src/Forms/Prism.Forms.Regions/Regions/Adapters/RegionAdapterMappings.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/Adapters/RegionAdapterMappings.cs
index fcfb985418..4a4fedc19a 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/Adapters/RegionAdapterMappings.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Adapters/RegionAdapterMappings.cs
@@ -4,7 +4,7 @@
using Prism.Ioc;
using Prism.Properties;
-namespace Prism.Regions.Adapters
+namespace Prism.Navigation.Regions.Adapters
{
///
/// This class maps with .
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Adapters/RegionItemsSourceTemplate.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Adapters/RegionItemsSourceTemplate.cs
similarity index 94%
rename from src/Forms/Prism.Forms.Regions/Regions/Adapters/RegionItemsSourceTemplate.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/Adapters/RegionItemsSourceTemplate.cs
index 1fdb366588..b765baf2c3 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/Adapters/RegionItemsSourceTemplate.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Adapters/RegionItemsSourceTemplate.cs
@@ -1,6 +1,6 @@
using Xamarin.Forms;
-namespace Prism.Regions.Adapters
+namespace Prism.Navigation.Regions.Adapters
{
// Implementation Note:
// In discussing with PureWeen, it is best to provide a ContentView and provide a
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Adapters/ScrollViewRegionAdapter.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Adapters/ScrollViewRegionAdapter.cs
similarity index 97%
rename from src/Forms/Prism.Forms.Regions/Regions/Adapters/ScrollViewRegionAdapter.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/Adapters/ScrollViewRegionAdapter.cs
index 9ebf834297..8836c44f84 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/Adapters/ScrollViewRegionAdapter.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Adapters/ScrollViewRegionAdapter.cs
@@ -3,10 +3,9 @@
using System.Linq;
using Prism.Ioc;
using Prism.Properties;
-using Prism.Regions.Behaviors;
using Xamarin.Forms;
-namespace Prism.Regions.Adapters
+namespace Prism.Navigation.Regions.Adapters
{
///
/// Adapter that creates a new and monitors its
diff --git a/src/Forms/Prism.Forms.Regions/Regions/AllActiveRegion.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/AllActiveRegion.cs
similarity index 90%
rename from src/Forms/Prism.Forms.Regions/Regions/AllActiveRegion.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/AllActiveRegion.cs
index 93baa9bf2c..4f43a6ade1 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/AllActiveRegion.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/AllActiveRegion.cs
@@ -1,8 +1,7 @@
using System;
using Prism.Properties;
-using Xamarin.Forms;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Region that keeps all the views in it as active. Deactivation of views is not allowed.
@@ -20,7 +19,7 @@ public class AllActiveRegion : Region
///
/// The view to deactivate.
/// Every time this method is called.
- public override void Deactivate(VisualElement view)
+ public override void Deactivate(object view)
{
throw new InvalidOperationException(Resources.DeactiveNotPossibleException);
}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/AutoPopulateRegionBehavior.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Behaviors/AutoPopulateRegionBehavior.cs
similarity index 95%
rename from src/Forms/Prism.Forms.Regions/Regions/Behaviors/AutoPopulateRegionBehavior.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/Behaviors/AutoPopulateRegionBehavior.cs
index d6f17c1788..fc7d507372 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/AutoPopulateRegionBehavior.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Behaviors/AutoPopulateRegionBehavior.cs
@@ -1,9 +1,10 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
+using Prism.Ioc;
using Xamarin.Forms;
-namespace Prism.Regions.Behaviors
+namespace Prism.Navigation.Regions.Behaviors
{
///
/// Populates the target region with the views registered to it in the .
@@ -93,7 +94,7 @@ public virtual void OnViewRegistered(object sender, ViewRegisteredEventArgs e)
if (e.RegionName == Region.Name)
{
- AddViewIntoRegion((VisualElement)e.GetView());
+ AddViewIntoRegion((VisualElement)e.GetView(ContainerLocator.Container));
}
}
}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/BindRegionContextToVisualElementBehavior.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Behaviors/BindRegionContextToVisualElementBehavior.cs
similarity index 97%
rename from src/Forms/Prism.Forms.Regions/Regions/Behaviors/BindRegionContextToVisualElementBehavior.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/Behaviors/BindRegionContextToVisualElementBehavior.cs
index e84320712d..a1137913a9 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/BindRegionContextToVisualElementBehavior.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Behaviors/BindRegionContextToVisualElementBehavior.cs
@@ -4,10 +4,10 @@
using Prism.Common;
using Xamarin.Forms;
-namespace Prism.Regions.Behaviors
+namespace Prism.Navigation.Regions.Behaviors
{
///
- /// Defines a behavior that forwards the
+ /// Defines a behavior that forwards the
/// to the views in the region.
///
public class BindRegionContextToVisualElementBehavior : IRegionBehavior
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/ClearChildViewsRegionBehavior.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Behaviors/ClearChildViewsRegionBehavior.cs
similarity index 87%
rename from src/Forms/Prism.Forms.Regions/Regions/Behaviors/ClearChildViewsRegionBehavior.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/Behaviors/ClearChildViewsRegionBehavior.cs
index fa014bb178..70b3a9448b 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/ClearChildViewsRegionBehavior.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Behaviors/ClearChildViewsRegionBehavior.cs
@@ -1,7 +1,8 @@
using System;
+using System.Linq;
using Xamarin.Forms;
-namespace Prism.Regions.Behaviors
+namespace Prism.Navigation.Regions.Behaviors
{
///
/// Behavior that removes the RegionManager attached property of all the views in a region once the RegionManager property of a region becomes null.
@@ -34,7 +35,7 @@ public static bool GetClearChildViews(BindableObject target)
if (target == null)
throw new ArgumentNullException(nameof(target));
- return (bool)target.GetValue(ClearChildViewsRegionBehavior.ClearChildViewsProperty);
+ return (bool)target.GetValue(ClearChildViewsProperty);
}
///
@@ -47,7 +48,7 @@ public static void SetClearChildViews(BindableObject target, bool value)
if (target == null)
throw new ArgumentNullException(nameof(target));
- target.SetValue(ClearChildViewsRegionBehavior.ClearChildViewsProperty, value);
+ target.SetValue(ClearChildViewsProperty, value);
}
///
@@ -55,12 +56,12 @@ public static void SetClearChildViews(BindableObject target, bool value)
///
protected override void OnAttach()
{
- this.Region.PropertyChanged += Region_PropertyChanged;
+ Region.PropertyChanged += Region_PropertyChanged;
}
private static void ClearChildViews(IRegion region)
{
- foreach (var view in region.Views)
+ foreach (var view in region.Views.OfType())
{
if (GetClearChildViews(view))
{
@@ -73,9 +74,9 @@ private void Region_PropertyChanged(object sender, System.ComponentModel.Propert
{
if (e.PropertyName == "RegionManager")
{
- if (this.Region.RegionManager == null)
+ if (Region.RegionManager == null)
{
- ClearChildViews(this.Region);
+ ClearChildViews(Region);
}
}
}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/DelayedRegionCreationBehavior.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Behaviors/DelayedRegionCreationBehavior.cs
similarity index 96%
rename from src/Forms/Prism.Forms.Regions/Regions/Behaviors/DelayedRegionCreationBehavior.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/Behaviors/DelayedRegionCreationBehavior.cs
index 56d4080f5e..6104d86baa 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/DelayedRegionCreationBehavior.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Behaviors/DelayedRegionCreationBehavior.cs
@@ -5,11 +5,11 @@
using System.Globalization;
using Prism.Behaviors;
using Prism.Extensions;
+using Prism.Navigation.Regions.Adapters;
using Prism.Properties;
-using Prism.Regions.Adapters;
using Xamarin.Forms;
-namespace Prism.Regions.Behaviors
+namespace Prism.Navigation.Regions.Behaviors
{
///
/// Behavior that creates a new , when the control that will host the (see )
@@ -99,7 +99,7 @@ public void Detach()
/// Called when the is updating it's collection.
///
/// The .
- /// The instance containing the event data.
+ /// The instance containing the event data.
public void OnUpdatingRegions(object sender, EventArgs e)
{
TryCreateRegion();
@@ -153,7 +153,7 @@ protected virtual IRegion CreateRegion(VisualElement targetElement, string regio
page.Behaviors.Add(cleanupBehavior);
if (region is INavigationServiceAware nsa)
{
- nsa.NavigationService = Prism.Navigation.Xaml.Navigation.GetNavigationService(page);
+ nsa.NavigationService = global::Prism.Navigation.Xaml.Navigation.GetNavigationService(page);
}
return region;
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/DestructibleRegionBehavior.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Behaviors/DestructibleRegionBehavior.cs
similarity index 94%
rename from src/Forms/Prism.Forms.Regions/Regions/Behaviors/DestructibleRegionBehavior.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/Behaviors/DestructibleRegionBehavior.cs
index b6bb31de22..ed561d6b10 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/DestructibleRegionBehavior.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Behaviors/DestructibleRegionBehavior.cs
@@ -1,8 +1,7 @@
using System.Collections.Specialized;
using Prism.Common;
-using Prism.Navigation;
-namespace Prism.Regions.Behaviors
+namespace Prism.Navigation.Regions.Behaviors
{
///
/// Provides a Behavior to Destroy the View/ViewModel when the View is removed from the Region's Views
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/IHostAwareRegionBehavior.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Behaviors/IHostAwareRegionBehavior.cs
similarity index 94%
rename from src/Forms/Prism.Forms.Regions/Regions/Behaviors/IHostAwareRegionBehavior.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/Behaviors/IHostAwareRegionBehavior.cs
index 7f63dc7c77..dc983def10 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/IHostAwareRegionBehavior.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Behaviors/IHostAwareRegionBehavior.cs
@@ -1,6 +1,6 @@
using Xamarin.Forms;
-namespace Prism.Regions.Behaviors
+namespace Prism.Navigation.Regions.Behaviors
{
///
/// Defines a that not allows extensible behaviors on regions which also interact
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/RegionActiveAwareBehavior.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Behaviors/RegionActiveAwareBehavior.cs
similarity index 87%
rename from src/Forms/Prism.Forms.Regions/Regions/Behaviors/RegionActiveAwareBehavior.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/Behaviors/RegionActiveAwareBehavior.cs
index 067b18072b..795f1f747e 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/RegionActiveAwareBehavior.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Behaviors/RegionActiveAwareBehavior.cs
@@ -4,17 +4,17 @@
using Prism.Common;
using Xamarin.Forms;
-namespace Prism.Regions.Behaviors
+namespace Prism.Navigation.Regions.Behaviors
{
///
- /// Behavior that monitors a object and
+ /// Behavior that monitors a object and
/// changes the value for the property when
- /// an object that implements gets added or removed
+ /// an object that implements gets added or removed
/// from the collection.
///
///
/// This class can also sync the active state for any scoped regions directly on the view based on the .
- /// If you use the method with the createRegionManagerScope option, the scoped manager will be attached to the view.
+ /// If you use the method with the createRegionManagerScope option, the scoped manager will be attached to the view.
///
public class RegionActiveAwareBehavior : IRegionBehavior
{
@@ -33,7 +33,7 @@ public class RegionActiveAwareBehavior : IRegionBehavior
///
public void Attach()
{
- INotifyCollectionChanged collection = this.GetCollection();
+ INotifyCollectionChanged collection = GetCollection();
if (collection != null)
{
collection.CollectionChanged += OnCollectionChanged;
@@ -45,7 +45,7 @@ public void Attach()
///
public void Detach()
{
- INotifyCollectionChanged collection = this.GetCollection();
+ INotifyCollectionChanged collection = GetCollection();
if (collection != null)
{
collection.CollectionChanged -= OnCollectionChanged;
@@ -82,15 +82,15 @@ private void InvokeOnSynchronizedActiveAwareChildren(object item, Action e.ActiveViews);
+ var activeViews = regionManager.Regions.SelectMany(e => e.ActiveViews).OfType();
var syncActiveViews = activeViews.Where(ShouldSyncActiveState);
@@ -115,7 +115,7 @@ private bool ShouldSyncActiveState(VisualElement view)
private INotifyCollectionChanged GetCollection()
{
- return this.Region.ActiveViews;
+ return Region.ActiveViews;
}
}
}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/RegionManagerRegistrationBehavior.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Behaviors/RegionManagerRegistrationBehavior.cs
similarity index 99%
rename from src/Forms/Prism.Forms.Regions/Regions/Behaviors/RegionManagerRegistrationBehavior.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/Behaviors/RegionManagerRegistrationBehavior.cs
index 37bca6f28e..be794e2567 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/RegionManagerRegistrationBehavior.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Behaviors/RegionManagerRegistrationBehavior.cs
@@ -3,7 +3,7 @@
using Prism.Properties;
using Xamarin.Forms;
-namespace Prism.Regions.Behaviors
+namespace Prism.Navigation.Regions.Behaviors
{
///
/// Subscribes to a static event from the in order to register the target
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/RegionMemberLifetimeBehavior.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Behaviors/RegionMemberLifetimeBehavior.cs
similarity index 97%
rename from src/Forms/Prism.Forms.Regions/Regions/Behaviors/RegionMemberLifetimeBehavior.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/Behaviors/RegionMemberLifetimeBehavior.cs
index 2bbab455e8..ea1eec209d 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/RegionMemberLifetimeBehavior.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Behaviors/RegionMemberLifetimeBehavior.cs
@@ -5,7 +5,7 @@
using Prism.Common;
using Xamarin.Forms;
-namespace Prism.Regions.Behaviors
+namespace Prism.Navigation.Regions.Behaviors
{
///
/// The RegionMemberLifetimeBehavior determines if items should be removed from the
@@ -13,10 +13,10 @@ namespace Prism.Regions.Behaviors
///
///
/// The monitors the
- /// collection to discover items that transition into a deactivated state.
+ /// collection to discover items that transition into a deactivated state.
///
/// The behavior checks the removed items for either the
- /// or the (in that order) to determine if it should be kept
+ /// or the (in that order) to determine if it should be kept
/// alive on removal.
///
/// If the item in the collection is a , it will
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs
similarity index 92%
rename from src/Forms/Prism.Forms.Regions/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs
index d8ad59fdee..80d7608024 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs
@@ -3,14 +3,14 @@
using Prism.Properties;
using Xamarin.Forms;
-namespace Prism.Regions.Behaviors
+namespace Prism.Navigation.Regions.Behaviors
{
///
- /// Behavior that synchronizes the property of a with
- /// the control that hosts the Region. It does this by setting the
+ /// Behavior that synchronizes the property of a with
+ /// the control that hosts the Region. It does this by setting the
/// Dependency Property on the host control.
- ///
- /// This behavior allows the usage of two way databinding of the RegionContext from XAML.
+ ///
+ /// This behavior allows the usage of two way databinding of the RegionContext from XAML.
///
public class SyncRegionContextWithHostBehavior : RegionBehavior, IHostAwareRegionBehavior
{
@@ -18,7 +18,7 @@ public class SyncRegionContextWithHostBehavior : RegionBehavior, IHostAwareRegio
private VisualElement _hostControl;
///
- /// Name that identifies the SyncRegionContextWithHostBehavior behavior in a collection of RegionsBehaviors.
+ /// Name that identifies the SyncRegionContextWithHostBehavior behavior in a collection of RegionsBehaviors.
///
public static readonly string BehaviorKey = "SyncRegionContextWithHost";
@@ -54,7 +54,7 @@ protected override void OnAttach()
{
if (HostControl != null)
{
- // Sync values initially.
+ // Sync values initially.
SynchronizeRegionContext();
// Now register for events to keep them in sync
diff --git a/src/Forms/Prism.Forms.Regions/Regions/DefaultRegionManagerAccessor.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/DefaultRegionManagerAccessor.cs
similarity index 98%
rename from src/Forms/Prism.Forms.Regions/Regions/DefaultRegionManagerAccessor.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/DefaultRegionManagerAccessor.cs
index 5402362485..11a45305a6 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/DefaultRegionManagerAccessor.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/DefaultRegionManagerAccessor.cs
@@ -2,7 +2,7 @@
using Prism.Ioc;
using Xamarin.Forms;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
internal class DefaultRegionManagerAccessor : IRegionManagerAccessor
{
diff --git a/src/Forms/Prism.Forms.Regions/Regions/IActiveRegionHelper.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/IActiveRegionHelper.cs
similarity index 72%
rename from src/Forms/Prism.Forms.Regions/Regions/IActiveRegionHelper.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/IActiveRegionHelper.cs
index 6685df2ba0..eb194ca987 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/IActiveRegionHelper.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/IActiveRegionHelper.cs
@@ -1,4 +1,4 @@
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
internal interface IActiveRegionHelper
{
diff --git a/src/Forms/Prism.Forms.Regions/Regions/INavigationServiceAware.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/INavigationServiceAware.cs
similarity index 50%
rename from src/Forms/Prism.Forms.Regions/Regions/INavigationServiceAware.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/INavigationServiceAware.cs
index e7eab7a728..d080839b14 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/INavigationServiceAware.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/INavigationServiceAware.cs
@@ -1,9 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using Prism.Navigation;
-
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
internal interface INavigationServiceAware
{
diff --git a/src/Forms/Prism.Forms.Regions/Regions/IRegionManagerAccessor.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/IRegionManagerAccessor.cs
similarity index 96%
rename from src/Forms/Prism.Forms.Regions/Regions/IRegionManagerAccessor.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/IRegionManagerAccessor.cs
index 88a2bb394e..525a7ee20c 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/IRegionManagerAccessor.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/IRegionManagerAccessor.cs
@@ -1,7 +1,7 @@
using System;
using Xamarin.Forms;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Provides an abstraction on top of the RegionManager static members.
@@ -19,7 +19,7 @@ public interface IRegionManagerAccessor
/// Gets the value for the RegionName attached property.
///
/// The object to adapt. This is typically a container (i.e a control).
- /// The name of the region that should be created when
+ /// The name of the region that should be created when
/// the RegionManager is also set in this element.
string GetRegionName(VisualElement element);
diff --git a/src/Forms/Prism.Forms.Regions/Regions/ItemMetadata.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/ItemMetadata.cs
similarity index 98%
rename from src/Forms/Prism.Forms.Regions/Regions/ItemMetadata.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/ItemMetadata.cs
index 713d8895ab..d775f43a18 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/ItemMetadata.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/ItemMetadata.cs
@@ -1,7 +1,7 @@
using System;
using Xamarin.Forms;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Defines a class that wraps an item and adds metadata for it.
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Navigation/RegionNavigationContentLoader.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Navigation/RegionNavigationContentLoader.cs
similarity index 95%
rename from src/Forms/Prism.Forms.Regions/Regions/Navigation/RegionNavigationContentLoader.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/Navigation/RegionNavigationContentLoader.cs
index 44ed0af565..4d1ff1c736 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/Navigation/RegionNavigationContentLoader.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Navigation/RegionNavigationContentLoader.cs
@@ -5,11 +5,10 @@
using Prism.Common;
using Prism.Ioc;
using Prism.Ioc.Internals;
-using Prism.Mvvm;
using Prism.Properties;
using Xamarin.Forms;
-namespace Prism.Regions.Navigation
+namespace Prism.Navigation.Regions.Navigation
{
///
/// Implementation of that relies on a
@@ -41,7 +40,7 @@ public RegionNavigationContentLoader(IContainerExtension container)
/// is created and added to the region.
///
/// when a new view cannot be created for the navigation request.
- public object LoadContent(IRegion region, INavigationContext navigationContext)
+ public object LoadContent(IRegion region, NavigationContext navigationContext)
{
if (region == null)
throw new ArgumentNullException(nameof(region));
@@ -105,7 +104,7 @@ protected virtual object CreateNewRegionItem(string candidateTargetContract)
///
/// The navigation contract.
/// The candidate contract to seek within the and to use, if not found, when resolving from the container.
- protected virtual string GetContractFromNavigationContext(INavigationContext navigationContext)
+ protected virtual string GetContractFromNavigationContext(NavigationContext navigationContext)
{
if (navigationContext == null) throw new ArgumentNullException(nameof(navigationContext));
@@ -150,7 +149,8 @@ protected virtual IEnumerable GetCandidatesFromRegion(IRegion reg
private IEnumerable GetCandidatesFromRegionViews(IRegion region, string candidateNavigationContract)
{
- return region.Views.Where(v => ViewIsMatch(v.GetType(), candidateNavigationContract));
+ return region.Views.OfType()
+ .Where(v => ViewIsMatch(v.GetType(), candidateNavigationContract));
}
private static bool ViewIsMatch(Type viewType, string navigationSegment)
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Navigation/RegionNavigationService.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Navigation/RegionNavigationService.cs
similarity index 81%
rename from src/Forms/Prism.Forms.Regions/Regions/Navigation/RegionNavigationService.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/Navigation/RegionNavigationService.cs
index 5bcb5b9982..122e2c14bf 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/Navigation/RegionNavigationService.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Navigation/RegionNavigationService.cs
@@ -1,13 +1,11 @@
using System;
-using System.Collections.Generic;
using System.Linq;
using Prism.Common;
using Prism.Ioc;
-using Prism.Navigation;
using Prism.Properties;
using Xamarin.Forms;
-namespace Prism.Regions.Navigation
+namespace Prism.Navigation.Regions.Navigation
{
///
/// Provides navigation for regions.
@@ -49,7 +47,7 @@ public RegionNavigationService(IContainerExtension container, IRegionNavigationC
///
public event EventHandler Navigating;
- private void RaiseNavigating(INavigationContext navigationContext)
+ private void RaiseNavigating(NavigationContext navigationContext)
{
Navigating?.Invoke(this, new RegionNavigationEventArgs(navigationContext));
}
@@ -59,7 +57,7 @@ private void RaiseNavigating(INavigationContext navigationContext)
///
public event EventHandler Navigated;
- private void RaiseNavigated(INavigationContext navigationContext)
+ private void RaiseNavigated(NavigationContext navigationContext)
{
Navigated?.Invoke(this, new RegionNavigationEventArgs(navigationContext));
}
@@ -69,28 +67,18 @@ private void RaiseNavigated(INavigationContext navigationContext)
///
public event EventHandler NavigationFailed;
- private void RaiseNavigationFailed(INavigationContext navigationContext, Exception error)
+ private void RaiseNavigationFailed(NavigationContext navigationContext, Exception error)
{
NavigationFailed?.Invoke(this, new RegionNavigationFailedEventArgs(navigationContext, error));
}
- ///
- /// Initiates navigation to the specified target.
- ///
- /// The target.
- /// A callback to execute when the navigation request is completed.
- public void RequestNavigate(Uri target, Action navigationCallback)
- {
- RequestNavigate(target, navigationCallback, null);
- }
-
///
/// Initiates navigation to the specified target.
///
/// The target.
/// A callback to execute when the navigation request is completed.
/// The navigation parameters specific to the navigation request.
- public void RequestNavigate(Uri target, Action navigationCallback, INavigationParameters regionParameters)
+ public void RequestNavigate(Uri target, Action navigationCallback, INavigationParameters regionParameters)
{
if (navigationCallback == null)
throw new ArgumentNullException(nameof(navigationCallback));
@@ -105,7 +93,7 @@ public void RequestNavigate(Uri target, Action navigati
}
}
- private void DoNavigate(Uri source, Action navigationCallback, INavigationParameters regionParameters)
+ private void DoNavigate(Uri source, Action navigationCallback, INavigationParameters regionParameters)
{
if (source == null)
throw new ArgumentNullException(nameof(source));
@@ -119,19 +107,19 @@ private void DoNavigate(Uri source, Action navigationCa
RequestCanNavigateFromOnCurrentlyActiveView(
_currentNavigationContext,
navigationCallback,
- Region.ActiveViews.ToArray(),
+ Region.ActiveViews.OfType().ToArray(),
0);
}
private void RequestCanNavigateFromOnCurrentlyActiveView(
- INavigationContext navigationContext,
- Action navigationCallback,
+ NavigationContext navigationContext,
+ Action navigationCallback,
VisualElement[] activeViews,
int currentViewIndex)
{
if (currentViewIndex < activeViews.Length)
{
- if (activeViews[currentViewIndex] is IConfirmRegionNavigationRequest vetoingView)
+ if (activeViews[currentViewIndex] is IConfirmNavigationRequest vetoingView)
{
// the current active view implements IConfirmNavigationRequest, request confirmation
// providing a callback to resume the navigation request
@@ -169,12 +157,12 @@ private void RequestCanNavigateFromOnCurrentlyActiveView(
}
private void RequestCanNavigateFromOnCurrentlyActiveViewModel(
- INavigationContext navigationContext,
- Action navigationCallback,
+ NavigationContext navigationContext,
+ Action navigationCallback,
VisualElement[] activeViews,
int currentViewIndex)
{
- if (activeViews[currentViewIndex].BindingContext is IConfirmRegionNavigationRequest vetoingViewModel)
+ if (activeViews[currentViewIndex].BindingContext is IConfirmNavigationRequest vetoingViewModel)
{
// the data model for the current active view implements IConfirmNavigationRequest, request confirmation
// providing a callback to resume the navigation request
@@ -206,7 +194,7 @@ private void RequestCanNavigateFromOnCurrentlyActiveViewModel(
currentViewIndex + 1);
}
- private void ExecuteNavigation(INavigationContext navigationContext, object[] activeViews, Action navigationCallback)
+ private void ExecuteNavigation(NavigationContext navigationContext, object[] activeViews, Action navigationCallback)
{
try
{
@@ -231,7 +219,7 @@ private void ExecuteNavigation(INavigationContext navigationContext, object[] ac
// The view can be informed of navigation
MvvmHelpers.OnNavigatedTo(view, navigationContext);
- navigationCallback(new RegionNavigationResult(navigationContext, true));
+ navigationCallback(new NavigationResult(navigationContext, true));
// Raise the navigated event when navigation is completed.
RaiseNavigated(navigationContext);
@@ -249,16 +237,16 @@ private static bool PersistInHistory(object view)
return persist;
}
- private void NotifyNavigationFailed(INavigationContext navigationContext, Action navigationCallback, Exception e)
+ private void NotifyNavigationFailed(NavigationContext navigationContext, Action navigationCallback, Exception e)
{
var navigationResult =
- e != null ? new RegionNavigationResult(navigationContext, e) : new RegionNavigationResult(navigationContext, false);
+ e != null ? new NavigationResult(navigationContext, e) : new NavigationResult(navigationContext, false);
navigationCallback(navigationResult);
RaiseNavigationFailed(navigationContext, e);
}
- private static void NotifyActiveViewsNavigatingFrom(INavigationContext navigationContext, object[] activeViews)
+ private static void NotifyActiveViewsNavigatingFrom(NavigationContext navigationContext, object[] activeViews)
{
foreach (var item in activeViews)
{
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Region.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Region.cs
similarity index 85%
rename from src/Forms/Prism.Forms.Regions/Regions/Region.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/Region.cs
index 72b8bc2490..8f1bcefbcf 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/Region.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Region.cs
@@ -4,13 +4,10 @@
using System.Linq;
using Prism.Ioc;
using Prism.Mvvm;
-using Prism.Navigation;
using Prism.Properties;
-using Prism.Regions.Behaviors;
-using Prism.Regions.Navigation;
using Xamarin.Forms;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Implementation of that allows multiple active views.
@@ -21,7 +18,7 @@ public class Region : BindableBase, IRegion, INavigationServiceAware
private IRegionManager _regionManager;
private IRegionNavigationService _regionNavigationService;
- private Comparison _sort;
+ private Comparison
/// The view to activate.
- public virtual void Activate(VisualElement view)
+ public virtual void Activate(object view)
{
var itemMetadata = GetItemMetadataOrThrow(view);
@@ -221,7 +218,7 @@ public virtual void Activate(VisualElement view)
/// Marks the specified view as inactive.
///
/// The view to deactivate.
- public virtual void Deactivate(VisualElement view)
+ public virtual void Deactivate(object view)
{
var itemMetadata = GetItemMetadataOrThrow(view);
@@ -231,13 +228,22 @@ public virtual void Deactivate(VisualElement view)
}
}
+ ///
+ /// Add a View by name.
+ ///
+ ///
+ ///
+ /// Xamarin.Forms is in maintenance mode. This feature is not being supported.
+ ///
+ public IRegionManager Add(string viewName) => throw new NotImplementedException();
+
/// Adds a new view to the region.
///
/// Adds a new view to the region.
///
/// The view to add.
/// The that is set on the view if it is a . It will be the current region manager when using this overload.
- public IRegionManager Add(VisualElement view)
+ public IRegionManager Add(object view)
{
return Add(view, null, false);
}
@@ -248,7 +254,7 @@ public IRegionManager Add(VisualElement view)
/// The view to add.
/// The name of the view. This can be used to retrieve it later by calling .
/// The that is set on the view if it is a . It will be the current region manager when using this overload.
- public IRegionManager Add(VisualElement view, string viewName)
+ public IRegionManager Add(object view, string viewName)
{
if (string.IsNullOrEmpty(viewName))
{
@@ -265,31 +271,36 @@ public IRegionManager Add(VisualElement view, string viewName)
/// The name of the view. This can be used to retrieve it later by calling .
/// When , the added view will receive a new instance of , otherwise it will use the current region manager for this region.
/// The that is set on the view if it is a .
- public virtual IRegionManager Add(VisualElement view, string viewName, bool createRegionManagerScope)
+ public virtual IRegionManager Add(object view, string viewName, bool createRegionManagerScope)
{
IRegionManager manager = createRegionManagerScope ? RegionManager.CreateRegionManager() : RegionManager;
InnerAdd(view, viewName, manager);
return manager;
}
- private void InnerAdd(VisualElement view, string viewName, IRegionManager scopedRegionManager)
+ private void InnerAdd(object view, string viewName, IRegionManager scopedRegionManager)
{
if (ItemMetadataCollection.FirstOrDefault(x => x.Item == view) != null)
{
- throw new InvalidOperationException(Resources.RegionViewExistsException);
+ throw new RegionViewException(Resources.RegionViewExistsException);
+ }
+
+ if (view is not VisualElement visualElement)
+ {
+ throw new RegionViewException(Resources.RegionViewIsNotVisualElementException);
}
- var itemMetadata = new ItemMetadata(view);
+ var itemMetadata = new ItemMetadata(visualElement);
if (!string.IsNullOrEmpty(viewName))
{
if (ItemMetadataCollection.FirstOrDefault(x => x.Name == viewName) != null)
{
- throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, Resources.RegionViewNameExistsException, viewName));
+ throw new RegionViewException(string.Format(CultureInfo.InvariantCulture, Resources.RegionViewNameExistsException, viewName));
}
itemMetadata.Name = viewName;
}
- Xaml.RegionManager.SetRegionManager(view, scopedRegionManager);
+ Xaml.RegionManager.SetRegionManager(visualElement, scopedRegionManager);
ItemMetadataCollection.Add(itemMetadata);
}
@@ -299,7 +310,7 @@ private void InnerAdd(VisualElement view, string viewName, IRegionManager scoped
///
/// The name used when adding the view to the region.
/// Returns the named view or if the view with does not exist in the current region.
- public virtual VisualElement GetView(string viewName)
+ public virtual object GetView(string viewName)
{
if (string.IsNullOrEmpty(viewName))
{
@@ -320,15 +331,20 @@ public virtual VisualElement GetView(string viewName)
/// Removes the specified view from the region.
///
/// The view to remove.
- public void Remove(VisualElement view)
+ public void Remove(object view)
{
+ if (view is not VisualElement visualElement)
+ {
+ throw new Exception("View is not a Visual Element");
+ }
+
var itemMetadata = GetItemMetadataOrThrow(view);
ItemMetadataCollection.Remove(itemMetadata);
- if (Xaml.RegionManager.GetRegionManager(view) == RegionManager)
+ if (Xaml.RegionManager.GetRegionManager(visualElement) == RegionManager)
{
- view.ClearValue(Xaml.RegionManager.RegionManagerProperty);
+ visualElement.ClearValue(Xaml.RegionManager.RegionManagerProperty);
}
}
@@ -413,5 +429,11 @@ private static int ViewSortHintAttributeComparison(ViewSortHintAttribute x, View
}
}
}
+
+ ///
+ public void RequestNavigate(Uri target, Action navigationCallback, INavigationParameters navigationParameters)
+ {
+ _regionNavigationService.RequestNavigate(target, navigationCallback, navigationParameters);
+ }
}
}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/RegionCollection.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/RegionCollection.cs
similarity index 98%
rename from src/Forms/Prism.Forms.Regions/Regions/RegionCollection.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/RegionCollection.cs
index c9e2516ab7..378f6d2d95 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/RegionCollection.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/RegionCollection.cs
@@ -6,7 +6,7 @@
using System.Linq;
using Prism.Properties;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
internal class RegionCollection : IRegionCollection
{
@@ -66,7 +66,7 @@ public void Add(IRegion region)
}
_regions.Add(region);
- region.RegionManager = this.regionManager;
+ region.RegionManager = regionManager;
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, region, 0));
}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/RegionContext.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/RegionContext.cs
similarity index 96%
rename from src/Forms/Prism.Forms.Regions/Regions/RegionContext.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/RegionContext.cs
index b0456ed29c..cbc5ad20a1 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/RegionContext.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/RegionContext.cs
@@ -1,9 +1,9 @@
using System;
using Prism.Common;
-using Prism.Regions.Behaviors;
+using Prism.Navigation.Regions.Behaviors;
using Xamarin.Forms;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Class that holds methods to Set and Get the RegionContext from a BindableObject.
diff --git a/src/Forms/Prism.Forms.Regions/Regions/RegionManager.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/RegionManager.cs
similarity index 77%
rename from src/Forms/Prism.Forms.Regions/Regions/RegionManager.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/RegionManager.cs
index 35aab5b36b..81822c539a 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/RegionManager.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/RegionManager.cs
@@ -4,12 +4,10 @@
using Prism.Common;
using Prism.Ioc;
using Prism.Ioc.Internals;
-using Prism.Navigation;
using Prism.Properties;
-using Prism.Regions.Navigation;
using Xamarin.Forms;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// This class is responsible for maintaining a collection of regions and attaching regions to controls.
@@ -49,6 +47,20 @@ public IRegionManager AddToRegion(string regionName, string targetName)
return Regions[regionName].Add(view);
}
+ ///
+ /// Add a view to the Views collection of a Region. Note that the region must already exist in this .
+ ///
+ /// The name of the region to add a view to
+ /// The view to add to the views collection
+ /// The RegionManager, to easily add several views.
+ public IRegionManager AddToRegion(string regionName, object view)
+ {
+ if (!Regions.ContainsRegionWithName(regionName))
+ throw new ArgumentException(string.Format(Thread.CurrentThread.CurrentCulture, Resources.RegionNotFound, regionName), nameof(regionName));
+
+ return Regions[regionName].Add(view);
+ }
+
///
/// Creates a new region manager.
///
@@ -89,13 +101,21 @@ public IRegionManager RegisterViewWithRegion(string regionName, string targetNam
}
///
- /// Navigates the specified region manager.
+ /// Associate a view with a region, using a delegate to resolve a concrete instance of the view.
+ /// When the region get's displayed, this delegate will be called and the result will be added to the
+ /// views collection of the region.
///
- /// The name of the region to call Navigate on.
- /// The URI of the content to display.
- /// The navigation callback.
- public void RequestNavigate(string regionName, Uri target, Action navigationCallback) =>
- RequestNavigate(regionName, target, navigationCallback, null);
+ /// The name of the region to associate the view with.
+ /// The delegate used to resolve a concrete instance of the view.
+ /// The , for adding several views easily
+ public IRegionManager RegisterViewWithRegion(string regionName, Func getContentDelegate)
+ {
+ var regionViewRegistry = ContainerLocator.Container.Resolve();
+
+ regionViewRegistry.RegisterViewWithRegion(regionName, getContentDelegate);
+
+ return this;
+ }
///
/// This method allows an to locate a specified region and navigate in it to the specified target , passing a navigation callback and an instance of , which holds a collection of object parameters.
@@ -104,7 +124,7 @@ public void RequestNavigate(string regionName, Uri target, ActionA that represents the target where the region will navigate.
/// The navigation callback that will be executed after the navigation is completed.
/// An instance of , which holds a collection of object parameters.
- public void RequestNavigate(string regionName, Uri target, Action navigationCallback, INavigationParameters navigationParameters)
+ public void RequestNavigate(string regionName, Uri target, Action navigationCallback, INavigationParameters navigationParameters)
{
try
{
@@ -121,7 +141,7 @@ public void RequestNavigate(string regionName, Uri target, Action
/// Region that allows a maximum of one active view at a time.
@@ -14,7 +13,7 @@ public class SingleActiveRegion : Region
/// The view to activate.
/// If there is an active view before calling this method,
/// that view will be deactivated automatically.
- public override void Activate(VisualElement view)
+ public override void Activate(object view)
{
var currentActiveView = ActiveViews.FirstOrDefault();
diff --git a/src/Forms/Prism.Forms.Regions/Regions/ViewsCollection.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/ViewsCollection.cs
similarity index 91%
rename from src/Forms/Prism.Forms.Regions/Regions/ViewsCollection.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/ViewsCollection.cs
index d707457b92..51b29b2c26 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/ViewsCollection.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/ViewsCollection.cs
@@ -7,7 +7,7 @@
using Prism.Mvvm;
using Xamarin.Forms;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Implementation of that takes an of
@@ -65,7 +65,7 @@ public Comparison SortComparison
///
/// The object to locate in the collection.
/// if is found in the collection; otherwise, .
- public bool Contains(VisualElement value) => filteredItems.Contains(value);
+ public bool Contains(object value) => filteredItems.Contains(value);
///
///Returns an enumerator that iterates through the collection.
@@ -73,7 +73,7 @@ public Comparison SortComparison
///
///A that can be used to iterate through the collection.
///
- public IEnumerator GetEnumerator() => filteredItems.GetEnumerator();
+ public IEnumerator GetEnumerator() => filteredItems.GetEnumerator();
///
///Returns an enumerator that iterates through a collection.
@@ -83,7 +83,7 @@ public Comparison SortComparison
///
IEnumerator IEnumerable.GetEnumerator()
{
- return this.GetEnumerator();
+ return GetEnumerator();
}
///
@@ -125,12 +125,12 @@ private void MonitorAllMetadataItems()
///
private void RemoveAllMetadataMonitors()
{
- foreach (var item in this._monitoredItems)
+ foreach (var item in _monitoredItems)
{
- item.Key.MetadataChanged -= this.OnItemMetadataChanged;
+ item.Key.MetadataChanged -= OnItemMetadataChanged;
}
- this._monitoredItems.Clear();
+ _monitoredItems.Clear();
}
///
@@ -174,7 +174,7 @@ private void OnItemMetadataChanged(object sender, EventArgs e)
bool foundInfo = _monitoredItems.TryGetValue(itemMetadata, out MonitorInfo monitorInfo);
if (!foundInfo) return;
- if (this.Filter(itemMetadata))
+ if (Filter(itemMetadata))
{
if (!monitorInfo.IsInList)
{
@@ -182,7 +182,7 @@ private void OnItemMetadataChanged(object sender, EventArgs e)
// as in our list so we can consider this
// an Add.
monitorInfo.IsInList = true;
- this.UpdateFilteredItemsList();
+ UpdateFilteredItemsList();
NotifyAdd(itemMetadata.Item);
}
}
@@ -192,7 +192,7 @@ private void OnItemMetadataChanged(object sender, EventArgs e)
// tracking list, but should not remove any monitoring in
// case it fits our filter in the future.
monitorInfo.IsInList = false;
- this.RemoveFromFilteredList(itemMetadata.Item);
+ RemoveFromFilteredList(itemMetadata.Item);
}
}
@@ -218,11 +218,11 @@ private void SourceCollectionChanged(object sender, NotifyCollectionChangedEvent
}
// If we're sorting we can't predict how
- // the collection has changed on an add so we
+ // the collection has changed on an add so we
// resort to a reset notification.
if (SortComparison != null)
{
- this.NotifyReset();
+ NotifyReset();
}
break;
@@ -230,19 +230,19 @@ private void SourceCollectionChanged(object sender, NotifyCollectionChangedEvent
case NotifyCollectionChangedAction.Remove:
foreach (ItemMetadata itemMetadata in e.OldItems)
{
- this.RemoveMetadataMonitor(itemMetadata);
- if (this.Filter(itemMetadata))
+ RemoveMetadataMonitor(itemMetadata);
+ if (Filter(itemMetadata))
{
- this.RemoveFromFilteredList(itemMetadata.Item);
+ RemoveFromFilteredList(itemMetadata.Item);
}
}
break;
default:
- this.ResetAllMonitors();
- this.UpdateFilteredItemsList();
- this.NotifyReset();
+ ResetAllMonitors();
+ UpdateFilteredItemsList();
+ NotifyReset();
break;
}
@@ -283,12 +283,12 @@ public RegionItemComparer(Comparison comparer)
public override int Compare(VisualElement x, VisualElement y)
{
- if (this.comparer == null)
+ if (comparer == null)
{
return 0;
}
- return this.comparer(x, y);
+ return comparer(x, y);
}
}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Xaml/RegionManager.cs b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Xaml/RegionManager.cs
similarity index 98%
rename from src/Forms/Prism.Forms.Regions/Regions/Xaml/RegionManager.cs
rename to src/Forms/Prism.Forms.Regions/Navigation/Regions/Xaml/RegionManager.cs
index c96c67320c..5e289db8aa 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/Xaml/RegionManager.cs
+++ b/src/Forms/Prism.Forms.Regions/Navigation/Regions/Xaml/RegionManager.cs
@@ -4,12 +4,12 @@
using Prism.Common;
using Prism.Events;
using Prism.Ioc;
+using Prism.Navigation.Regions.Adapters;
+using Prism.Navigation.Regions.Behaviors;
using Prism.Properties;
-using Prism.Regions.Adapters;
-using Prism.Regions.Behaviors;
using Xamarin.Forms;
-namespace Prism.Regions.Xaml
+namespace Prism.Navigation.Regions.Xaml
{
///
/// A class to provide Bindable Properties and helpers for Regions.
diff --git a/src/Forms/Prism.Forms.Regions/Prism.Forms.Regions.csproj b/src/Forms/Prism.Forms.Regions/Prism.Forms.Regions.csproj
index 83159dbfbf..180804026f 100644
--- a/src/Forms/Prism.Forms.Regions/Prism.Forms.Regions.csproj
+++ b/src/Forms/Prism.Forms.Regions/Prism.Forms.Regions.csproj
@@ -13,16 +13,13 @@ Prism.Forms.Regions helps you more easily design and build rich, flexible, and e
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+ TrueTrue
diff --git a/src/Forms/Prism.Forms.Regions/Properties/AssemblyInfo.cs b/src/Forms/Prism.Forms.Regions/Properties/AssemblyInfo.cs
index 1e8f340bba..eb1b0599f0 100644
--- a/src/Forms/Prism.Forms.Regions/Properties/AssemblyInfo.cs
+++ b/src/Forms/Prism.Forms.Regions/Properties/AssemblyInfo.cs
@@ -1,5 +1,5 @@
using System.Runtime.CompilerServices;
using Xamarin.Forms;
-[assembly: XmlnsDefinition("http://prismlibrary.com", "Prism.Regions.Xaml")]
+[assembly: XmlnsDefinition("http://prismlibrary.com", "Prism.Navigation.Regions.Xaml")]
[assembly: InternalsVisibleTo("Prism.Forms.Regions.Tests")]
diff --git a/src/Forms/Prism.Forms.Regions/Properties/Resources.Designer.cs b/src/Forms/Prism.Forms.Regions/Properties/Resources.Designer.cs
index 6f3de9544b..d737b72762 100644
--- a/src/Forms/Prism.Forms.Regions/Properties/Resources.Designer.cs
+++ b/src/Forms/Prism.Forms.Regions/Properties/Resources.Designer.cs
@@ -19,7 +19,7 @@ namespace Prism.Properties {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
@@ -290,6 +290,15 @@ internal static string RegionViewExistsException {
}
}
+ ///
+ /// Looks up a localized string similar to View is not a Visual Element..
+ ///
+ internal static string RegionViewIsNotVisualElementException {
+ get {
+ return ResourceManager.GetString("RegionViewIsNotVisualElementException", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to View with name '{0}' already exists in the region..
///
diff --git a/src/Forms/Prism.Forms.Regions/Properties/Resources.resx b/src/Forms/Prism.Forms.Regions/Properties/Resources.resx
index e421f89102..0ccd4ef14f 100644
--- a/src/Forms/Prism.Forms.Regions/Properties/Resources.resx
+++ b/src/Forms/Prism.Forms.Regions/Properties/Resources.resx
@@ -203,6 +203,9 @@
View already exists in region.
+
+ View is not a Visual Element.
+
View with name '{0}' already exists in the region.
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Adapters/IRegionAdapter.cs b/src/Forms/Prism.Forms.Regions/Regions/Adapters/IRegionAdapter.cs
deleted file mode 100644
index 70387f7918..0000000000
--- a/src/Forms/Prism.Forms.Regions/Regions/Adapters/IRegionAdapter.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using Xamarin.Forms;
-
-namespace Prism.Regions.Adapters
-{
- ///
- /// Defines an interfaces to adapt an object and bind it to a new .
- ///
- public interface IRegionAdapter
- {
- ///
- /// Adapts an object and binds it to a new .
- ///
- /// The object to adapt.
- /// The name of the region to be created.
- /// The new instance of that the is bound to.
- IRegion Initialize(VisualElement regionTarget, string regionName);
- }
-}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/IRegionBehavior.cs b/src/Forms/Prism.Forms.Regions/Regions/Behaviors/IRegionBehavior.cs
deleted file mode 100644
index 819937e1bf..0000000000
--- a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/IRegionBehavior.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System.Text;
-
-namespace Prism.Regions.Behaviors
-{
- ///
- /// Interface for allowing extensible behavior on regions.
- ///
- public interface IRegionBehavior
- {
- ///
- /// The region that this behavior is extending.
- ///
- IRegion Region { get; set; }
-
- ///
- /// Attaches the behavior to the specified region.
- ///
- void Attach();
- }
-}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/IRegionBehaviorCollection.cs b/src/Forms/Prism.Forms.Regions/Regions/Behaviors/IRegionBehaviorCollection.cs
deleted file mode 100644
index 3012f64fe6..0000000000
--- a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/IRegionBehaviorCollection.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using System.Collections.Generic;
-
-namespace Prism.Regions.Behaviors
-{
- ///
- /// Defines the interface for a collection of classes on a Region.
- ///
- public interface IRegionBehaviorCollection : IEnumerable>
- {
-
- ///
- /// Adds a to the collection, using the specified key as an indexer.
- ///
- ///
- /// The key that specifies the type of that's added.
- ///
- /// The to add.
- void Add(string key, IRegionBehavior regionBehavior);
-
- ///
- /// Checks if a with the specified key is already present.
- ///
- /// The key to use to find a particular .
- ///
- bool ContainsKey(string key);
-
- ///
- /// Gets the with the specified key.
- ///
- /// The registered
- IRegionBehavior this[string key] { get; }
- }
-}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/IRegionBehaviorFactory.cs b/src/Forms/Prism.Forms.Regions/Regions/Behaviors/IRegionBehaviorFactory.cs
deleted file mode 100644
index 4e500cb92c..0000000000
--- a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/IRegionBehaviorFactory.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-namespace Prism.Regions.Behaviors
-{
- ///
- /// Interface for RegionBehaviorFactories. This factory allows the registration of the default set of RegionBehaviors, that will
- /// be added to the s of all s, unless overridden on a 'per-region' basis.
- ///
- public interface IRegionBehaviorFactory : IEnumerable
- {
- ///
- /// Adds a particular type of RegionBehavior if it was not already registered. the string is used to check if the behavior is already present
- ///
- /// Type of the behavior to add.
- /// The behavior key that's used to find if a certain behavior is already added.
- void AddIfMissing(string behaviorKey)
- where TBehavior : IRegionBehavior;
-
- ///
- /// Determines whether a behavior with the specified key already exists
- ///
- /// The behavior key.
- ///
- /// if a behavior with the specified key is present; otherwise, .
- ///
- bool ContainsKey(string behaviorKey);
-
- ///
- /// Creates an instance of the BehaviorType that's registered using the specified key.
- ///
- /// The key that's used to register a behavior type.
- /// The created behavior.
- IRegionBehavior CreateFromKey(string key);
- }
-}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/RegionBehavior.cs b/src/Forms/Prism.Forms.Regions/Regions/Behaviors/RegionBehavior.cs
deleted file mode 100644
index 6284c4437e..0000000000
--- a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/RegionBehavior.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using System;
-using Prism.Properties;
-
-namespace Prism.Regions.Behaviors
-{
- ///
- /// Provides a base class for region's behaviors.
- ///
- public abstract class RegionBehavior : IRegionBehavior
- {
- private IRegion region;
-
- ///
- /// Behavior's attached region.
- ///
- public IRegion Region
- {
- get => region;
- set
- {
- if (IsAttached)
- {
- throw new InvalidOperationException(Resources.RegionBehaviorRegionCannotBeSetAfterAttach);
- }
-
- region = value;
- }
- }
-
- ///
- /// Returns if the behavior is attached to a region, otherwise.
- ///
- public bool IsAttached { get; private set; }
-
- ///
- /// Attaches the behavior to the region.
- ///
- public void Attach()
- {
- if (region == null)
- {
- throw new InvalidOperationException(Resources.RegionBehaviorAttachCannotBeCallWithNullRegion);
- }
-
- IsAttached = true;
- OnAttach();
- }
-
- ///
- /// Override this method to perform the logic after the behavior has been attached.
- ///
- protected abstract void OnAttach();
- }
-}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/RegionBehaviorCollection.cs b/src/Forms/Prism.Forms.Regions/Regions/Behaviors/RegionBehaviorCollection.cs
deleted file mode 100644
index c1f47c45ef..0000000000
--- a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/RegionBehaviorCollection.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-
-namespace Prism.Regions.Behaviors
-{
- ///
- /// A collection of instances, that are stored and retrieved by Key.
- ///
- public class RegionBehaviorCollection : IRegionBehaviorCollection
- {
- private readonly IRegion _region;
- private readonly Dictionary _behaviors = new Dictionary();
-
- ///
- /// Initializes a new instance of the class and associates it with a region.
- ///
- /// The region to associate the behavior collection with.
- public RegionBehaviorCollection(IRegion region)
- {
- _region = region;
- }
-
- ///
- /// Gets the with the specified key.
- ///
- /// The RegionBehavior that's registered with the key.
- public IRegionBehavior this[string key] => _behaviors[key];
-
- ///
- /// Adds a to the collection, using the specified key as an indexer.
- ///
- /// The key that specifies the type of that's added.
- /// The to add.
- ///
- /// Thrown is the parameter is Null,
- /// or if the parameter is Null.
- ///
- /// Thrown if a behavior with the specified Key parameter already exists.
- public void Add(string key, IRegionBehavior regionBehavior)
- {
- if (key == null)
- throw new ArgumentNullException(nameof(key));
-
- if (regionBehavior == null)
- throw new ArgumentNullException(nameof(regionBehavior));
-
- if (_behaviors.ContainsKey(key))
- throw new ArgumentException("Could not add duplicate behavior with same key.", nameof(key));
-
- _behaviors.Add(key, regionBehavior);
- regionBehavior.Region = _region;
-
- regionBehavior.Attach();
- }
-
- ///
- /// Checks if a with the specified key is already present.
- ///
- /// The key to use to find a particular .
- ///
- public bool ContainsKey(string key) => _behaviors.ContainsKey(key);
-
- ///
- /// Returns an enumerator that iterates through the collection.
- ///
- ///
- /// A that can be used to iterate through the collection.
- ///
- public IEnumerator> GetEnumerator() => _behaviors.GetEnumerator();
-
- ///
- /// Returns an enumerator that iterates through a collection.
- ///
- ///
- /// An object that can be used to iterate through the collection.
- ///
- IEnumerator IEnumerable.GetEnumerator() => _behaviors.GetEnumerator();
- }
-}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/RegionBehaviorFactory.cs b/src/Forms/Prism.Forms.Regions/Regions/Behaviors/RegionBehaviorFactory.cs
deleted file mode 100644
index 85d584af3e..0000000000
--- a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/RegionBehaviorFactory.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Globalization;
-using Prism.Ioc;
-using Prism.Properties;
-
-namespace Prism.Regions.Behaviors
-{
- ///
- /// Defines a factory that allows the registration of the default set of , that will
- /// be added to the of all s, unless overridden on a 'per-region' basis.
- ///
- public class RegionBehaviorFactory : IRegionBehaviorFactory
- {
- private readonly IContainerProvider _container;
- private readonly Dictionary _registeredBehaviors = new Dictionary();
-
- ///
- /// Initializes a new instance of .
- ///
- /// used to create the instance of the behavior from its .
- public RegionBehaviorFactory(IContainerExtension container)
- {
- _container = container;
- }
-
- ///
- /// Adds a particular type of RegionBehavior if it was not already registered. The string is used to check if the behavior is already present
- ///
- /// Type of the behavior to add.
- /// The behavior key that's used to find if a certain behavior is already added.
- public void AddIfMissing(string behaviorKey)
- where TBehavior : IRegionBehavior
- {
- if (behaviorKey == null)
- {
- throw new ArgumentNullException(nameof(behaviorKey));
- }
-
- var behaviorType = typeof(TBehavior);
-
- // Only add the behaviorKey if it doesn't already exists.
- if (_registeredBehaviors.ContainsKey(behaviorKey))
- {
- return;
- }
-
- _registeredBehaviors.Add(behaviorKey, behaviorType);
- }
-
- ///
- /// Creates an instance of the behavior that is registered using the specified key.
- ///
- /// The key that is used to register a behavior type.
- /// A new instance of the behavior.
- public IRegionBehavior CreateFromKey(string key)
- {
- if (!ContainsKey(key))
- {
- throw new ArgumentException(
- string.Format(CultureInfo.CurrentUICulture, Resources.TypeWithKeyNotRegistered, key), nameof(key));
- }
-
- return (IRegionBehavior)_container.Resolve(_registeredBehaviors[key]);
- }
-
-
- ///
- /// Returns an enumerator that iterates through the collection.
- ///
- ///
- /// A that can be used to iterate through the collection.
- ///
- /// 1
- public IEnumerator GetEnumerator() =>
- _registeredBehaviors.Keys.GetEnumerator();
-
- ///
- /// Returns an enumerator that iterates through a collection.
- ///
- ///
- /// An object that can be used to iterate through the collection.
- ///
- /// 2
- IEnumerator IEnumerable.GetEnumerator() =>
- GetEnumerator();
-
- ///
- /// Determines whether a behavior with the specified key already exists.
- ///
- /// The behavior key.
- ///
- /// if a behavior with the specified key is present; otherwise, .
- ///
- public bool ContainsKey(string behaviorKey) =>
- _registeredBehaviors.ContainsKey(behaviorKey);
- }
-}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/IRegion.cs b/src/Forms/Prism.Forms.Regions/Regions/IRegion.cs
deleted file mode 100644
index c47f7305ad..0000000000
--- a/src/Forms/Prism.Forms.Regions/Regions/IRegion.cs
+++ /dev/null
@@ -1,118 +0,0 @@
-using System;
-using System.ComponentModel;
-using Prism.Regions.Behaviors;
-using Prism.Regions.Navigation;
-using Xamarin.Forms;
-
-namespace Prism.Regions
-{
- ///
- /// Defines a model that can be used to compose views.
- ///
- public interface IRegion : INotifyPropertyChanged
- {
- ///
- /// Gets a readonly view of the collection of views in the region.
- ///
- /// An of all the added views.
- IViewsCollection Views { get; }
-
- ///
- /// Gets a readonly view of the collection of all the active views in the region.
- ///
- /// An of all the active views.
- IViewsCollection ActiveViews { get; }
-
- ///
- /// Gets or sets a context for the region. This value can be used by the user to share context with the views.
- ///
- /// The context value to be shared.
- object Context { get; set; }
-
- ///
- /// Gets the name of the region that uniquely identifies the region within a .
- ///
- /// The name of the region.
- string Name { get; set; }
-
- ///
- /// Gets or sets the comparison used to sort the views.
- ///
- /// The comparison to use.
- Comparison SortComparison { get; set; }
-
- ///Adds a new view to the region.
- ///
- /// Adds a new view to the region.
- ///
- /// The view to add.
- /// The that is set on the view if it is a . It will be the current region manager when using this overload.
- IRegionManager Add(VisualElement view);
-
- ///
- /// Adds a new view to the region.
- ///
- /// The view to add.
- /// The name of the view. This can be used to retrieve it later by calling .
- /// The that is set on the view if it is a . It will be the current region manager when using this overload.
- IRegionManager Add(VisualElement view, string viewName);
-
- ///
- /// Adds a new view to the region.
- ///
- /// The view to add.
- /// The name of the view. This can be used to retrieve it later by calling .
- /// When , the added view will receive a new instance of , otherwise it will use the current region manager for this region.
- /// The that is set on the view if it is a .
- IRegionManager Add(VisualElement view, string viewName, bool createRegionManagerScope);
-
- ///
- /// Removes the specified view from the region.
- ///
- /// The view to remove.
- void Remove(VisualElement view);
-
- ///
- /// Removes all views from the region.
- ///
- void RemoveAll();
-
- ///
- /// Marks the specified view as active.
- ///
- /// The view to activate.
- void Activate(VisualElement view);
-
- ///
- /// Marks the specified view as inactive.
- ///
- /// The view to deactivate.
- void Deactivate(VisualElement view);
-
- ///
- /// Returns the view instance that was added to the region using a specific name.
- ///
- /// The name used when adding the view to the region.
- /// Returns the named view or if the view with does not exist in the current region.
- VisualElement GetView(string viewName);
-
- ///
- /// Gets or sets the that will be passed to the views when adding them to the region, unless the view is added by specifying createRegionManagerScope as .
- ///
- /// The where this is registered.
- /// This is usually used by implementations of and should not be
- /// used by the developer explicitly.
- IRegionManager RegionManager { get; set; }
-
- ///
- /// Gets the collection of s that can extend the behavior of regions.
- ///
- IRegionBehaviorCollection Behaviors { get; }
-
- ///
- /// Gets or sets the navigation service.
- ///
- /// The navigation service.
- IRegionNavigationService NavigationService { get; set; }
- }
-}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/IRegionCollection.cs b/src/Forms/Prism.Forms.Regions/Regions/IRegionCollection.cs
deleted file mode 100644
index 63afc9fca3..0000000000
--- a/src/Forms/Prism.Forms.Regions/Regions/IRegionCollection.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Linq;
-
-namespace Prism.Regions
-{
- ///
- /// Defines a collection of uniquely identified by their Name.
- ///
- public interface IRegionCollection : IEnumerable, INotifyCollectionChanged
- {
- ///
- /// Gets the IRegion with the name received as index.
- ///
- /// Name of the region to be retrieved.
- /// The identified with the requested name.
- IRegion this[string regionName] { get; }
-
- ///
- /// Adds a to the collection.
- ///
- /// Region to be added to the collection.
- void Add(IRegion region);
-
- ///
- /// Removes a from the collection.
- ///
- /// Name of the region to be removed.
- /// if the region was removed from the collection, otherwise .
- bool Remove(string regionName);
-
- ///
- /// Checks if the collection contains a with the name received as parameter.
- ///
- /// The name of the region to look for.
- /// if the region is contained in the collection, otherwise .
- bool ContainsRegionWithName(string regionName);
-
- ///
- /// Adds a region to the with the name received as argument.
- ///
- /// The name to be given to the region.
- /// The region to be added to the .
- /// Thrown if is .
- /// Thrown if and 's name do not match and the is not .
- void Add(string regionName, IRegion region);
- }
-}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/IRegionManager.cs b/src/Forms/Prism.Forms.Regions/Regions/IRegionManager.cs
deleted file mode 100644
index b0677ec37a..0000000000
--- a/src/Forms/Prism.Forms.Regions/Regions/IRegionManager.cs
+++ /dev/null
@@ -1,76 +0,0 @@
-using System;
-using Prism.Navigation;
-using Prism.Regions.Navigation;
-
-namespace Prism.Regions
-{
- ///
- /// Defines an interface to manage a set of regions and to attach regions to objects (typically controls).
- ///
- public interface IRegionManager
- {
- ///
- /// Gets a collection of that identify each region by name. You can use this collection to add or remove regions to the current region manager.
- ///
- IRegionCollection Regions { get; }
-
- ///
- /// Creates a new region manager.
- ///
- /// A new region manager that can be used as a different scope from the current region manager.
- IRegionManager CreateRegionManager();
-
- ///
- /// Add a view to the Views collection of a Region. Note that the region must already exist in this .
- ///
- /// The name of the region to add a view to
- /// The view to add to the views collection
- /// The RegionManager, to easily add several views.
- IRegionManager AddToRegion(string regionName, string targetName);
-
- ///
- /// Associate a view with a region, by registering a type. When the region get's displayed
- /// this type will be resolved using the ServiceLocator into a concrete instance. The instance
- /// will be added to the Views collection of the region
- ///
- /// The name of the region to associate the view with.
- /// The type of the view to register with the
- /// The , for adding several views easily
- IRegionManager RegisterViewWithRegion(string regionName, string targetName);
-
- ///
- /// Associate a view with a region, by registering a type. When the region get's displayed
- /// this type will be resolved using the ServiceLocator into a concrete instance. The instance
- /// will be added to the Views collection of the region
- ///
- /// The name of the region to associate the view with.
- /// The type of the view to register with the .
- /// The , for adding several views easily
- IRegionManager RegisterViewWithRegion(string regionName, Type viewType);
-
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The name of the Region to navigate to.
- /// The navigation target
- /// The callback executed when the navigation request is completed.
- ///
- /// Convenience overloads for this method can be found as extension methods on the
- /// class.
- ///
- void RequestNavigate(string regionName, Uri target, Action navigationCallback);
-
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The name of the Region to navigate to.
- /// The navigation target
- /// The callback executed when the navigation request is completed.
- /// The navigation parameters specific to the navigation request.
- ///
- /// Convenience overloads for this method can be found as extension methods on the
- /// class.
- ///
- void RequestNavigate(string regionName, Uri target, Action navigationCallback, INavigationParameters navigationParameters);
- }
-}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/IRegionManagerExtensions.cs b/src/Forms/Prism.Forms.Regions/Regions/IRegionManagerExtensions.cs
deleted file mode 100644
index 6cd60626e6..0000000000
--- a/src/Forms/Prism.Forms.Regions/Regions/IRegionManagerExtensions.cs
+++ /dev/null
@@ -1,123 +0,0 @@
-using System;
-using Prism.Navigation;
-using Prism.Regions.Navigation;
-
-namespace Prism.Regions
-{
- ///
- /// NavigationExtensions for the
- ///
- public static class IRegionManagerExtensions
- {
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The navigation object.
- /// The name of the Region to navigate to.
- /// The navigation target
- public static void RequestNavigate(this IRegionManager regionManager, string regionName, string target)
- {
- RequestNavigate(regionManager, regionName, target, nr => { });
- }
-
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The navigation object.
- /// The name of the Region to navigate to.
- /// The navigation target
- /// The callback executed when the navigation request is completed.
- public static void RequestNavigate(this IRegionManager regionManager, string regionName, string target, Action navigationCallback)
- {
- if (regionManager == null)
- throw new ArgumentNullException(nameof(regionManager));
-
- if (target == null)
- throw new ArgumentNullException(nameof(target));
-
- var targetUri = new Uri(target, UriKind.RelativeOrAbsolute);
-
- regionManager.RequestNavigate(regionName, targetUri, navigationCallback);
- }
-
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The navigation object.
- /// The name of the Region to navigate to.
- /// The navigation target
- public static void RequestNavigate(this IRegionManager regionManager, string regionName, Uri target)
- {
- if (regionManager == null)
- throw new ArgumentNullException(nameof(regionManager));
-
- regionManager.RequestNavigate(regionName, target, nr => { });
- }
-
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The navigation object.
- /// The name of the Region to navigate to.
- /// The navigation target
- /// The callback executed when the navigation request is completed.
- /// An instance of NavigationParameters, which holds a collection of object parameters.
- public static void RequestNavigate(this IRegionManager regionManager, string regionName, string target, Action navigationCallback, INavigationParameters regionParameters)
- {
- if (regionManager == null)
- throw new ArgumentNullException(nameof(regionManager));
-
- if (target == null)
- throw new ArgumentNullException(nameof(target));
-
- var targetUri = new Uri(target, UriKind.RelativeOrAbsolute);
-
- regionManager.RequestNavigate(regionName, targetUri, navigationCallback, regionParameters);
- }
-
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The RegionManager object.
- /// The name of the Region to navigate to.
- /// A Uri that represents the target where the region will navigate.
- /// An instance of NavigationParameters, which holds a collection of object parameters.
- public static void RequestNavigate(this IRegionManager regionManager, string regionName, Uri target, INavigationParameters regionParameters)
- {
- if (regionManager == null)
- throw new ArgumentNullException(nameof(regionManager));
-
- regionManager.RequestNavigate(regionName, target, nr => { }, regionParameters);
- }
-
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The RegionManager object.
- /// The name of the Region to navigate to.
- /// A string that represents the target where the region will navigate.
- /// An instance of NavigationParameters, which holds a collection of object parameters.
- public static void RequestNavigate(this IRegionManager regionManager, string regionName, string target, INavigationParameters regionParameters)
- {
- if (regionManager == null)
- throw new ArgumentNullException(nameof(regionManager));
-
- if (target == null)
- throw new ArgumentNullException(nameof(target));
-
- regionManager.RequestNavigate(regionName, new Uri(target, UriKind.RelativeOrAbsolute), nr => { }, regionParameters);
- }
-
- ///
- /// Associate a view with a region, by registering a type. When the region get's displayed
- /// this type will be resolved using the ServiceLocator into a concrete instance. The instance
- /// will be added to the Views collection of the region
- ///
- /// The type of the view to register with the .
- /// The current .
- /// The name of the region to associate the view with.
- /// The , for adding several views easily
- public static IRegionManager RegisterViewWithRegion(this IRegionManager regionManager, string regionName) =>
- regionManager.RegisterViewWithRegion(regionName, typeof(T));
- }
-}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/IViewsCollection.cs b/src/Forms/Prism.Forms.Regions/Regions/IViewsCollection.cs
deleted file mode 100644
index 5e571f8587..0000000000
--- a/src/Forms/Prism.Forms.Regions/Regions/IViewsCollection.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using Xamarin.Forms;
-
-namespace Prism.Regions
-{
- public interface IViewsCollection : IEnumerable, INotifyCollectionChanged
- {
- bool Contains(VisualElement element);
- }
-}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Navigation/IConfirmRegionNavigationRequest.cs b/src/Forms/Prism.Forms.Regions/Regions/Navigation/IConfirmRegionNavigationRequest.cs
deleted file mode 100644
index 73df7eeff1..0000000000
--- a/src/Forms/Prism.Forms.Regions/Regions/Navigation/IConfirmRegionNavigationRequest.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using System;
-
-namespace Prism.Regions.Navigation
-{
- ///
- /// Provides a way for objects involved in navigation to determine if a navigation request should continue.
- ///
- public interface IConfirmRegionNavigationRequest : IRegionAware
- {
- ///
- /// Determines whether this instance accepts being navigated away from.
- ///
- /// The navigation context.
- /// The callback to indicate when navigation can proceed.
- ///
- /// Implementors of this method do not need to invoke the callback before this method is completed,
- /// but they must ensure the callback is eventually invoked.
- ///
- void ConfirmNavigationRequest(INavigationContext navigationContext, Action continuationCallback);
- }
-}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Navigation/INavigateAsync.cs b/src/Forms/Prism.Forms.Regions/Regions/Navigation/INavigateAsync.cs
deleted file mode 100644
index 0b1bc49759..0000000000
--- a/src/Forms/Prism.Forms.Regions/Regions/Navigation/INavigateAsync.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-using System;
-using Prism.Navigation;
-
-namespace Prism.Regions.Navigation
-{
- ///
- /// Provides methods to perform navigation.
- ///
- ///
- /// Convenience overloads for the methods in this interface can be found as extension methods on the
- /// class.
- ///
- public interface INavigateAsync
- {
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The navigation target
- /// The callback executed when the navigation request is completed.
- ///
- /// Convenience overloads for this method can be found as extension methods on the
- /// class.
- ///
- void RequestNavigate(Uri target, Action navigationCallback);
-
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The navigation target
- /// The callback executed when the navigation request is completed.
- /// The navigation parameters specific to the navigation request.
- ///
- /// Convenience overloads for this method can be found as extension methods on the
- /// class.
- ///
- void RequestNavigate(Uri target, Action navigationCallback, INavigationParameters navigationParameters);
- }
-}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Navigation/INavigationContext.cs b/src/Forms/Prism.Forms.Regions/Regions/Navigation/INavigationContext.cs
deleted file mode 100644
index 91365e1a02..0000000000
--- a/src/Forms/Prism.Forms.Regions/Regions/Navigation/INavigationContext.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-using System;
-using Prism.Ioc.Internals;
-using Prism.Navigation;
-
-namespace Prism.Regions.Navigation
-{
- ///
- /// Encapsulates information about a navigation request.
- ///
- public interface INavigationContext
- {
- ///
- /// Gets the region navigation service.
- ///
- /// The navigation service.
- IRegionNavigationService NavigationService { get; }
-
- ///
- /// Gets the extracted from the URI and the object parameters passed in navigation.
- ///
- /// The URI query.
- INavigationParameters Parameters { get; }
-
- ///
- /// Gets the navigation URI.
- ///
- /// The navigation URI.
- Uri Uri { get; }
- }
-
- public static class INavigationContextExtensions
- {
- public static string NavigatedName(this INavigationContext context)
- {
- var uri = context.Uri;
- if (!uri.IsAbsoluteUri)
- {
- uri = new Uri(new Uri("nav://local.app"), context.Uri);
- }
-
- return uri.LocalPath.StartsWith("/") ? uri.LocalPath.Substring(1) : uri.LocalPath;
- }
- }
-}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Navigation/IRegionAware.cs b/src/Forms/Prism.Forms.Regions/Regions/Navigation/IRegionAware.cs
deleted file mode 100644
index 89659393e4..0000000000
--- a/src/Forms/Prism.Forms.Regions/Regions/Navigation/IRegionAware.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-namespace Prism.Regions.Navigation
-{
- ///
- /// Provides a way for objects involved in navigation to be notified of navigation activities.
- ///
- public interface IRegionAware
- {
- ///
- /// Called when the implementer has been navigated to.
- ///
- /// The navigation context.
- void OnNavigatedTo(INavigationContext navigationContext);
-
- ///
- /// Called to determine if this instance can handle the navigation request.
- ///
- /// The navigation context.
- ///
- /// if this instance accepts the navigation request; otherwise, .
- ///
- bool IsNavigationTarget(INavigationContext navigationContext);
-
- ///
- /// Called when the implementer is being navigated away from.
- ///
- /// The navigation context.
- void OnNavigatedFrom(INavigationContext navigationContext);
- }
-}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Navigation/IRegionNavigationContentLoader.cs b/src/Forms/Prism.Forms.Regions/Regions/Navigation/IRegionNavigationContentLoader.cs
deleted file mode 100644
index b1f7b01051..0000000000
--- a/src/Forms/Prism.Forms.Regions/Regions/Navigation/IRegionNavigationContentLoader.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System;
-
-namespace Prism.Regions.Navigation
-{
- ///
- /// Identifies the view in a region that is the target of a navigation request.
- ///
- public interface IRegionNavigationContentLoader
- {
- ///
- /// Gets the content to which the navigation request represented by applies.
- ///
- ///
- /// If none of the items in the region match the target of the navigation request, a new item
- /// will be created and added to the region.
- ///
- /// The region.
- /// The context representing the navigation request.
- /// The item to be the target of the navigation request.
- /// when a new item cannot be created for the navigation request.
- object LoadContent(IRegion region, INavigationContext navigationContext);
- }
-}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Navigation/IRegionNavigationJournalEntry.cs b/src/Forms/Prism.Forms.Regions/Regions/Navigation/IRegionNavigationJournalEntry.cs
deleted file mode 100644
index a03d66f2b5..0000000000
--- a/src/Forms/Prism.Forms.Regions/Regions/Navigation/IRegionNavigationJournalEntry.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System;
-using Prism.Navigation;
-
-namespace Prism.Regions.Navigation
-{
- ///
- /// An entry in an IRegionNavigationJournal representing the URI navigated to.
- ///
- public interface IRegionNavigationJournalEntry
- {
- ///
- /// Gets or sets the URI.
- ///
- /// The URI.
- Uri Uri { get; set; }
-
- ///
- /// Gets or sets the NavigationParameters instance.
- ///
- INavigationParameters Parameters { get; set; }
- }
-}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Navigation/IRegionNavigationResult.cs b/src/Forms/Prism.Forms.Regions/Regions/Navigation/IRegionNavigationResult.cs
deleted file mode 100644
index 64521c2994..0000000000
--- a/src/Forms/Prism.Forms.Regions/Regions/Navigation/IRegionNavigationResult.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using System;
-
-namespace Prism.Regions.Navigation
-{
- ///
- /// Represents the result of navigating to a URI.
- ///
- public interface IRegionNavigationResult
- {
- ///
- /// Gets the navigation context.
- ///
- /// The navigation context.
- INavigationContext Context { get; }
-
- ///
- /// Gets an exception that occurred while navigating.
- ///
- /// The exception.
- Exception Error { get; }
-
- ///
- /// Gets the result.
- ///
- /// The result.
- bool? Result { get; }
- }
-}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Navigation/IRegionNavigationService.cs b/src/Forms/Prism.Forms.Regions/Regions/Navigation/IRegionNavigationService.cs
deleted file mode 100644
index 885c1a6a08..0000000000
--- a/src/Forms/Prism.Forms.Regions/Regions/Navigation/IRegionNavigationService.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using System;
-
-namespace Prism.Regions.Navigation
-{
- ///
- /// Provides navigation for regions.
- ///
- public interface IRegionNavigationService : INavigateAsync
- {
- ///
- /// Gets or sets the region owning this service.
- ///
- /// A Region.
- IRegion Region { get; set; }
-
- ///
- /// Gets the journal.
- ///
- /// The journal.
- IRegionNavigationJournal Journal { get; }
-
- ///
- /// Raised when the region is about to be navigated to content.
- ///
- event EventHandler Navigating;
-
- ///
- /// Raised when the region is navigated to content.
- ///
- event EventHandler Navigated;
-
- ///
- /// Raised when a navigation request fails.
- ///
- event EventHandler NavigationFailed;
- }
-}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Navigation/NavigationAsyncExtensions.cs b/src/Forms/Prism.Forms.Regions/Regions/Navigation/NavigationAsyncExtensions.cs
deleted file mode 100644
index db20e11626..0000000000
--- a/src/Forms/Prism.Forms.Regions/Regions/Navigation/NavigationAsyncExtensions.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-using System;
-using Prism.Navigation;
-
-namespace Prism.Regions.Navigation
-{
- ///
- /// Provides additional methods to the interface.
- ///
- public static class NavigationAsyncExtensions
- {
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The navigation object.
- /// The navigation target
- public static void RequestNavigate(this INavigateAsync navigation, string target)
- {
- RequestNavigate(navigation, target, nr => { });
- }
-
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The navigation object.
- /// The navigation target
- /// The callback executed when the navigation request is completed.
- public static void RequestNavigate(this INavigateAsync navigation, string target, Action navigationCallback)
- {
- if (navigation == null)
- throw new ArgumentNullException(nameof(navigation));
-
- if (target == null)
- throw new ArgumentNullException(nameof(target));
-
- var targetUri = new Uri(target, UriKind.RelativeOrAbsolute);
-
- navigation.RequestNavigate(targetUri, navigationCallback);
- }
-
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The navigation object.
- /// The navigation target
- public static void RequestNavigate(this INavigateAsync navigation, Uri target)
- {
- if (navigation == null)
- throw new ArgumentNullException(nameof(navigation));
-
- navigation.RequestNavigate(target, nr => { });
- }
-
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The navigation object.
- /// The navigation target
- /// The callback executed when the navigation request is completed.
- /// An instance of NavigationParameters, which holds a collection of object parameters.
- public static void RequestNavigate(this INavigateAsync navigation, string target, Action navigationCallback, INavigationParameters regionParameters)
- {
- if (navigation == null)
- throw new ArgumentNullException(nameof(navigation));
-
- if (target == null)
- throw new ArgumentNullException(nameof(target));
-
- var targetUri = new Uri(target, UriKind.RelativeOrAbsolute);
-
- navigation.RequestNavigate(targetUri, navigationCallback, regionParameters);
- }
-
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The navigation object.
- /// A Uri that represents the target where the region will navigate.
- /// An instance of NavigationParameters, which holds a collection of object parameters.
- public static void RequestNavigate(this INavigateAsync navigation, Uri target, INavigationParameters regionParameters)
- {
- if (navigation == null)
- throw new ArgumentNullException(nameof(navigation));
-
- navigation.RequestNavigate(target, nr => { }, regionParameters);
- }
-
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The navigation object.
- /// A string that represents the target where the region will navigate.
- /// An instance of NavigationParameters, which holds a collection of object parameters.
- public static void RequestNavigate(this INavigateAsync navigation, string target, INavigationParameters regionParameters)
- {
- if (navigation == null)
- throw new ArgumentNullException(nameof(navigation));
-
- if (target == null)
- throw new ArgumentNullException(nameof(target));
-
- navigation.RequestNavigate(new Uri(target, UriKind.RelativeOrAbsolute), nr => { }, regionParameters);
- }
- }
-}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Navigation/NavigationContext.cs b/src/Forms/Prism.Forms.Regions/Regions/Navigation/NavigationContext.cs
deleted file mode 100644
index a813f6e3fd..0000000000
--- a/src/Forms/Prism.Forms.Regions/Regions/Navigation/NavigationContext.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-using System;
-using System.Collections.Generic;
-using Prism.Common;
-using Prism.Navigation;
-
-namespace Prism.Regions.Navigation
-{
- ///
- /// Encapsulates information about a navigation request.
- ///
- public class NavigationContext : INavigationContext
- {
- ///
- /// Initializes a new instance of the class for a region name and a
- /// .
- ///
- /// The navigation service.
- /// The Uri.
- public NavigationContext(IRegionNavigationService navigationService, Uri uri)
- : this(navigationService, uri, null)
- {
- }
-
- ///
- /// Initializes a new instance of the class for a region name and a
- /// .
- ///
- /// The navigation service.
- /// The navigation parameters.
- /// The Uri.
- public NavigationContext(IRegionNavigationService navigationService, Uri uri, INavigationParameters regionParameters)
- {
- NavigationService = navigationService;
- Uri = uri;
- Parameters = regionParameters ?? new NavigationParameters();
-
- var queryString = uri != null ? UriParsingHelper.EnsureAbsolute(uri).Query : null;
- if (!string.IsNullOrEmpty(queryString))
- {
- UpdateRegionParameters(new NavigationParameters(queryString));
- }
- }
-
- ///
- /// Gets the region navigation service.
- ///
- /// The navigation service.
- public IRegionNavigationService NavigationService { get; private set; }
-
- ///
- /// Gets the navigation URI.
- ///
- /// The navigation URI.
- public Uri Uri { get; }
-
- ///
- /// Gets the extracted from the URI and the object parameters passed in navigation.
- ///
- /// The URI query.
- public INavigationParameters Parameters { get; }
-
- private void UpdateRegionParameters(INavigationParameters regionParameters)
- {
- foreach (KeyValuePair parameter in regionParameters)
- {
- Parameters.Add(parameter.Key, parameter.Value);
- }
- }
- }
-}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Navigation/RegionNavigationJournal.cs b/src/Forms/Prism.Forms.Regions/Regions/Navigation/RegionNavigationJournal.cs
deleted file mode 100644
index 2919d3959d..0000000000
--- a/src/Forms/Prism.Forms.Regions/Regions/Navigation/RegionNavigationJournal.cs
+++ /dev/null
@@ -1,147 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-namespace Prism.Regions.Navigation
-{
- ///
- /// Provides journaling of current, back, and forward navigation within regions.
- ///
- public class RegionNavigationJournal : IRegionNavigationJournal
- {
- private readonly Stack _backStack = new Stack();
- private readonly Stack _forwardStack = new Stack();
-
- private bool _isNavigatingInternal;
-
- ///
- /// Gets or sets the target that implements INavigate.
- ///
- /// The INavigate implementation.
- ///
- /// This is set by the owner of this journal.
- ///
- public INavigateAsync NavigationTarget { get; set; }
-
- ///
- /// Gets the current navigation entry of the content that is currently displayed.
- ///
- /// The current entry.
- public IRegionNavigationJournalEntry CurrentEntry { get; private set; }
-
- ///
- /// Gets a value that indicates whether there is at least one entry in the back navigation history.
- ///
- /// true if the journal can go back; otherwise, false.
- public bool CanGoBack => _backStack.Count > 0;
-
- ///
- /// Gets a value that indicates whether there is at least one entry in the forward navigation history.
- ///
- ///
- /// true if this instance can go forward; otherwise, false.
- ///
- public bool CanGoForward => _forwardStack.Count > 0;
-
- ///
- /// Navigates to the most recent entry in the back navigation history, or does nothing if no entry exists in back navigation.
- ///
- public void GoBack()
- {
- if (CanGoBack)
- {
- IRegionNavigationJournalEntry entry = _backStack.Peek();
- InternalNavigate(
- entry,
- result =>
- {
- if (result)
- {
- if (CurrentEntry != null)
- {
- _forwardStack.Push(CurrentEntry);
- }
-
- _backStack.Pop();
- CurrentEntry = entry;
- }
- });
- }
- }
-
- ///
- /// Navigates to the most recent entry in the forward navigation history, or does nothing if no entry exists in forward navigation.
- ///
- public void GoForward()
- {
- if (CanGoForward)
- {
- IRegionNavigationJournalEntry entry = _forwardStack.Peek();
- InternalNavigate(
- entry,
- result =>
- {
- if (result)
- {
- if (CurrentEntry != null)
- {
- _backStack.Push(CurrentEntry);
- }
-
- _forwardStack.Pop();
- CurrentEntry = entry;
- }
- });
- }
- }
-
- ///
- /// Records the navigation to the entry..
- ///
- /// The entry to record.
- /// Determine if the view is added to the back stack or excluded from the history.
- public void RecordNavigation(IRegionNavigationJournalEntry entry, bool persistInHistory)
- {
- if (!_isNavigatingInternal)
- {
- if (CurrentEntry != null)
- {
- _backStack.Push(CurrentEntry);
- }
-
- _forwardStack.Clear();
-
- if (persistInHistory)
- CurrentEntry = entry;
- else
- CurrentEntry = null;
- }
- }
-
- ///
- /// Clears the journal of current, back, and forward navigation histories.
- ///
- public void Clear()
- {
- CurrentEntry = null;
- _backStack.Clear();
- _forwardStack.Clear();
- }
-
- private void InternalNavigate(IRegionNavigationJournalEntry entry, Action callback)
- {
- _isNavigatingInternal = true;
- NavigationTarget.RequestNavigate(
- entry.Uri,
- nr =>
- {
- _isNavigatingInternal = false;
-
- if (nr.Result.HasValue)
- {
- callback(nr.Result.Value);
- }
- },
- entry.Parameters);
- }
- }
-}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Navigation/RegionNavigationJournalEntry.cs b/src/Forms/Prism.Forms.Regions/Regions/Navigation/RegionNavigationJournalEntry.cs
deleted file mode 100644
index b87bb74f24..0000000000
--- a/src/Forms/Prism.Forms.Regions/Regions/Navigation/RegionNavigationJournalEntry.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using System;
-using System.Globalization;
-using Prism.Navigation;
-
-namespace Prism.Regions.Navigation
-{
- ///
- /// An entry in an IRegionNavigationJournal representing the URI navigated to.
- ///
- public class RegionNavigationJournalEntry : IRegionNavigationJournalEntry
- {
- ///
- /// Gets or sets the URI.
- ///
- /// The URI.
- public Uri Uri { get; set; }
-
- ///
- /// Gets or sets the NavigationParameters instance.
- ///
- public INavigationParameters Parameters { get; set; }
-
- ///
- /// Returns a that represents this instance.
- ///
- ///
- /// A that represents this instance.
- ///
- public override string ToString()
- {
- if (Uri != null)
- {
- return string.Format(CultureInfo.CurrentCulture, "RegionNavigationJournalEntry:'{0}'", Uri.ToString());
- }
-
- return base.ToString();
- }
- }
-}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Navigation/RegionNavigationResult.cs b/src/Forms/Prism.Forms.Regions/Regions/Navigation/RegionNavigationResult.cs
deleted file mode 100644
index ffb5c88f7f..0000000000
--- a/src/Forms/Prism.Forms.Regions/Regions/Navigation/RegionNavigationResult.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-using System;
-
-namespace Prism.Regions.Navigation
-{
- ///
- /// Represents the result of navigating to a URI.
- ///
- public class RegionNavigationResult : IRegionNavigationResult
- {
- ///
- /// Initializes a new instance of the class.
- ///
- /// The context.
- /// The result.
- public RegionNavigationResult(INavigationContext context, bool? result)
- {
- Context = context;
- Result = result;
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The context.
- /// The error.
- public RegionNavigationResult(INavigationContext context, Exception error)
- {
- Context = context;
- Error = error;
- Result = false;
- }
-
- ///
- /// Gets the result.
- ///
- /// The result.
- public bool? Result { get; }
-
- ///
- /// Gets an exception that occurred while navigating.
- ///
- /// The exception.
- public Exception Error { get; }
-
- ///
- /// Gets the navigation context.
- ///
- /// The navigation context.
- public INavigationContext Context { get; }
- }
-}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/ViewRegisteredEventArgs.cs b/src/Forms/Prism.Forms.Regions/Regions/ViewRegisteredEventArgs.cs
deleted file mode 100644
index 9825db318e..0000000000
--- a/src/Forms/Prism.Forms.Regions/Regions/ViewRegisteredEventArgs.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using System;
-
-namespace Prism.Regions
-{
- ///
- /// Argument class used by the event when a new content is registered.
- ///
- public class ViewRegisteredEventArgs : EventArgs
- {
- ///
- /// Initializes the ViewRegisteredEventArgs class.
- ///
- /// The region name to which the content was registered.
- /// The content which was registered.
- public ViewRegisteredEventArgs(string regionName, Func getViewDelegate)
- {
- GetView = getViewDelegate;
- RegionName = regionName;
- }
-
- ///
- /// Gets the region name to which the content was registered.
- ///
- public string RegionName { get; private set; }
-
- ///
- /// Gets the content which was registered.
- ///
- public Func GetView { get; private set; }
- }
-}
diff --git a/src/Forms/Prism.Forms/Navigation/INavigationResult.cs b/src/Forms/Prism.Forms/Navigation/INavigationResult.cs
deleted file mode 100644
index f76eda462b..0000000000
--- a/src/Forms/Prism.Forms/Navigation/INavigationResult.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using System;
-
-namespace Prism.Navigation
-{
- public interface INavigationResult
- {
- bool Success { get; }
-
- Exception Exception { get; }
- }
-
- public class NavigationResult : INavigationResult
- {
- public bool Success { get; set; }
-
- public Exception Exception { get; set; }
- }
-}
diff --git a/src/Forms/Prism.Forms/Navigation/NavigationException.cs b/src/Forms/Prism.Forms/Navigation/NavigationException.cs
deleted file mode 100644
index 19159706a0..0000000000
--- a/src/Forms/Prism.Forms/Navigation/NavigationException.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using System;
-using Xamarin.Forms;
-
-namespace Prism.Navigation
-{
- public class NavigationException : Exception
- {
- public const string CannotPopApplicationMainPage = "Cannot Pop Application MainPage";
- public const string CannotGoBackFromRoot = "Cannot GoBack from NavigationPage Root.";
- public const string GoBackToRootRequiresNavigationPage = "GoBackToRootAsync can only be called when the calling Page is within a NavigationPage.";
- public const string RelativeNavigationRequiresNavigationPage = "Removing views using the relative '../' syntax while navigating is only supported within a NavigationPage";
- public const string IConfirmNavigationReturnedFalse = "IConfirmNavigation returned false";
- public const string NoPageIsRegistered = "No Page has been registered with the provided key";
- public const string ErrorCreatingPage = "An error occurred while resolving the page. This is most likely the result of invalid XAML or other type initialization exception";
- public const string UnknownException = "An unknown error occurred. You may need to specify whether to Use Modal Navigation or not.";
-
- public NavigationException()
- {
- }
-
- public NavigationException(string message, Page page) : this(message, page, null)
- {
- }
-
- public NavigationException(string message, Page page, Exception innerException) : base(message, innerException)
- {
- Page = page;
- }
-
- public Page Page { get; }
- }
-}
diff --git a/src/Forms/Prism.Forms/Navigation/PageNavigationService.cs b/src/Forms/Prism.Forms/Navigation/PageNavigationService.cs
index 103078447b..382090704d 100644
--- a/src/Forms/Prism.Forms/Navigation/PageNavigationService.cs
+++ b/src/Forms/Prism.Forms/Navigation/PageNavigationService.cs
@@ -86,7 +86,6 @@ public virtual Task GoBackAsync(INavigationParameters paramet
/// If true a go back operation was successful. If false the go back operation failed.
protected async virtual Task GoBackInternal(INavigationParameters parameters, bool? useModalNavigation, bool animated)
{
- var result = new NavigationResult();
Page page = null;
try
{
@@ -102,8 +101,7 @@ protected async virtual Task GoBackInternal(INavigationParame
var canNavigate = await PageUtilities.CanNavigateAsync(page, segmentParameters);
if (!canNavigate)
{
- result.Exception = new NavigationException(NavigationException.IConfirmNavigationReturnedFalse, page);
- return result;
+ return new NavigationResult(new NavigationException(NavigationException.IConfirmNavigationReturnedFalse, page));
}
bool useModalForDoPop = UseModalGoBack(page, useModalNavigation);
@@ -116,22 +114,19 @@ protected async virtual Task GoBackInternal(INavigationParame
PageUtilities.OnNavigatedTo(previousPage, segmentParameters);
PageUtilities.DestroyPage(poppedPage);
- result.Success = true;
- return result;
+ return new NavigationResult();
}
}
catch (Exception ex)
{
- result.Exception = ex;
- return result;
+ return new NavigationResult(ex);
}
finally
{
NavigationSource = PageNavigationSource.Device;
}
- result.Exception = GetGoBackException(page, _applicationProvider.MainPage);
- return result;
+ return new NavigationResult(GetGoBackException(page, _applicationProvider.MainPage));
}
private static Exception GetGoBackException(Page currentPage, Page mainPage)
@@ -196,7 +191,6 @@ public virtual Task GoBackToRootAsync(INavigationParameters p
/// Only works when called from a View within a NavigationPage
protected async virtual Task GoBackToRootInternal(INavigationParameters parameters)
{
- var result = new NavigationResult();
Page page = null;
try
{
@@ -209,8 +203,7 @@ protected async virtual Task GoBackToRootInternal(INavigation
var canNavigate = await PageUtilities.CanNavigateAsync(page, parameters);
if (!canNavigate)
{
- result.Exception = new NavigationException(NavigationException.IConfirmNavigationReturnedFalse, page);
- return result;
+ return new NavigationResult(new NavigationException(NavigationException.IConfirmNavigationReturnedFalse, page));
}
List pagesToDestroy = page.Navigation.NavigationStack.ToList(); // get all pages to destroy
@@ -228,13 +221,11 @@ protected async virtual Task GoBackToRootInternal(INavigation
PageUtilities.OnNavigatedTo(root, parameters);
- result.Success = true;
- return result;
+ return new NavigationResult();
}
catch (Exception ex)
{
- result.Exception = ex;
- return result;
+ return new NavigationResult(ex);
}
}
@@ -341,7 +332,6 @@ public virtual Task NavigateAsync(Uri uri, INavigationParamet
///
protected async virtual Task NavigateInternal(Uri uri, INavigationParameters parameters, bool? useModalNavigation, bool animated)
{
- var result = new NavigationResult();
try
{
NavigationSource = PageNavigationSource.NavigationService;
@@ -351,21 +341,18 @@ protected async virtual Task NavigateInternal(Uri uri, INavig
if (uri.IsAbsoluteUri)
{
await ProcessNavigationForAbsoulteUri(navigationSegments, parameters, useModalNavigation, animated);
- result.Success = true;
- return result;
+ return new NavigationResult();
}
else
{
await ProcessNavigation(GetCurrentPage(), navigationSegments, parameters, useModalNavigation, animated);
- result.Success = true;
- return result;
+ return new NavigationResult();
}
}
catch (Exception ex)
{
- result.Exception = ex;
- return result;
+ return new NavigationResult(ex);
}
finally
{
diff --git a/src/Forms/Prism.Forms/Navigation/TabbedPages/INavigationServiceExtensions.cs b/src/Forms/Prism.Forms/Navigation/TabbedPages/INavigationServiceExtensions.cs
index 7aa531391a..120350bd59 100644
--- a/src/Forms/Prism.Forms/Navigation/TabbedPages/INavigationServiceExtensions.cs
+++ b/src/Forms/Prism.Forms/Navigation/TabbedPages/INavigationServiceExtensions.cs
@@ -77,10 +77,10 @@ public static async Task SelectTabAsync(this INavigationServi
}
catch (Exception ex)
{
- return new NavigationResult { Exception = ex };
+ return new NavigationResult(ex);
}
- return new NavigationResult { Success = true };
+ return new NavigationResult();
}
}
}
diff --git a/src/Maui/Prism.Maui/Common/MvvmHelpers.cs b/src/Maui/Prism.Maui/Common/MvvmHelpers.cs
index 279e5d47eb..7014445ff2 100644
--- a/src/Maui/Prism.Maui/Common/MvvmHelpers.cs
+++ b/src/Maui/Prism.Maui/Common/MvvmHelpers.cs
@@ -1,8 +1,8 @@
using System.ComponentModel;
using System.Reflection;
using Prism.Navigation;
+using Prism.Navigation.Regions;
using Prism.Navigation.Xaml;
-using Prism.Regions.Navigation;
using NavigationMode = Prism.Navigation.NavigationMode;
using TabbedPage = Microsoft.Maui.Controls.TabbedPage;
@@ -22,10 +22,10 @@ public static void InvokeViewAndViewModelAction(object view, Action action
action(viewModelAsT);
}
- if(view is Page page)
+ if (view is Page page)
{
var children = page.GetChildRegions();
- if(children is not null)
+ if (children is not null)
foreach (var child in children)
InvokeViewAndViewModelAction(child, action);
}
@@ -46,7 +46,7 @@ public static async Task InvokeViewAndViewModelActionAsync(object view, Func<
if (view is Page page)
{
var children = page.GetChildRegions();
- if(children is not null)
+ if (children is not null)
foreach (var child in children)
await InvokeViewAndViewModelActionAsync(child, action);
}
@@ -60,7 +60,7 @@ public static void DestroyPage(IView view)
InvokeViewAndViewModelAction(view, v => v.Destroy());
- if(view is Page page)
+ if (view is Page page)
{
page.Behaviors?.Clear();
page.BindingContext = null;
@@ -120,7 +120,7 @@ public static T GetImplementerFromViewOrViewModel(object view)
return null;
}
- public static bool IsNavigationTarget(object view, INavigationContext navigationContext)
+ public static bool IsNavigationTarget(object view, NavigationContext navigationContext)
{
var implementor = GetImplementerFromViewOrViewModel(view);
if (implementor is not null)
@@ -135,12 +135,12 @@ public static bool IsNavigationTarget(object view, INavigationContext navigation
return path == viewType.Name || path == viewType.FullName;
}
- public static void OnNavigatedFrom(object view, INavigationContext navigationContext)
+ public static void OnNavigatedFrom(object view, NavigationContext navigationContext)
{
InvokeViewAndViewModelAction(view, x => x.OnNavigatedFrom(navigationContext));
}
- public static void OnNavigatedTo(object view, INavigationContext navigationContext)
+ public static void OnNavigatedTo(object view, NavigationContext navigationContext)
{
InvokeViewAndViewModelAction(view, x => x.OnNavigatedTo(navigationContext));
}
@@ -301,7 +301,7 @@ public static async Task HandleNavigationPageGoBack(NavigationPage navigationPag
{
var navigationService = Navigation.Xaml.Navigation.GetNavigationService(navigationPage.CurrentPage);
var result = await navigationService.GoBackAsync();
- if(result.Exception is NavigationException navEx && navEx.Message == NavigationException.CannotPopApplicationMainPage)
+ if (result.Exception is NavigationException navEx && navEx.Message == NavigationException.CannotPopApplicationMainPage)
{
Application.Current.Quit();
}
diff --git a/src/Maui/Prism.Maui/Common/ObservableObject.cs b/src/Maui/Prism.Maui/Common/ObservableObject.cs
index 5ffa340839..814e26ed29 100644
--- a/src/Maui/Prism.Maui/Common/ObservableObject.cs
+++ b/src/Maui/Prism.Maui/Common/ObservableObject.cs
@@ -24,4 +24,4 @@ public T Value
get => (T)GetValue(ValueProperty);
set => SetValue(ValueProperty, value);
}
-}
\ No newline at end of file
+}
diff --git a/src/Maui/Prism.Maui/Ioc/RegionNavigationRegistrationExtensions.cs b/src/Maui/Prism.Maui/Ioc/RegionNavigationRegistrationExtensions.cs
index 086cb6c664..2edbc23519 100644
--- a/src/Maui/Prism.Maui/Ioc/RegionNavigationRegistrationExtensions.cs
+++ b/src/Maui/Prism.Maui/Ioc/RegionNavigationRegistrationExtensions.cs
@@ -1,12 +1,15 @@
-using Microsoft.Maui.Controls.Compatibility;
+using Microsoft.Maui.Controls.Compatibility;
using Prism.Mvvm;
-using Prism.Regions;
-using Prism.Regions.Adapters;
-using Prism.Regions.Behaviors;
-using Prism.Regions.Navigation;
+using Prism.Navigation.Regions;
+using Prism.Navigation.Regions.Adapters;
+using Prism.Navigation.Regions.Behaviors;
+using Prism.Navigation.Regions.Navigation;
namespace Prism.Ioc;
+///
+/// Provides common extensions for Service Registrations for Prism.Maui
+///
public static class RegionNavigationRegistrationExtensions
{
///
@@ -16,7 +19,7 @@ public static class RegionNavigationRegistrationExtensions
/// used to register type for Navigation.
/// The unique name to register with the View
public static IContainerRegistry RegisterForRegionNavigation(this IContainerRegistry containerRegistry, string name = null)
- where TView : View =>
+ where TView : View =>
containerRegistry.RegisterForNavigationWithViewModel(typeof(TView), null, name);
///
@@ -28,7 +31,7 @@ public static IContainerRegistry RegisterForRegionNavigation(this IContai
///
public static IContainerRegistry RegisterForRegionNavigation(this IContainerRegistry containerRegistry, string name = null)
where TView : View
- where TViewModel : class =>
+ where TViewModel : class =>
containerRegistry.RegisterForNavigationWithViewModel(typeof(TView), typeof(TViewModel), name);
private static IContainerRegistry RegisterForNavigationWithViewModel(this IContainerRegistry containerRegistry, Type viewType, Type viewModelType, string name)
@@ -38,7 +41,7 @@ private static IContainerRegistry RegisterForNavigationWithViewModel(this IConta
if (viewModelType is not null)
containerRegistry.Register(viewModelType);
-
+
containerRegistry.Register(viewType)
.RegisterInstance(new ViewRegistration
{
diff --git a/src/Maui/Prism.Maui/Navigation/INavigationResult.cs b/src/Maui/Prism.Maui/Navigation/INavigationResult.cs
deleted file mode 100644
index f40131b5cf..0000000000
--- a/src/Maui/Prism.Maui/Navigation/INavigationResult.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace Prism.Navigation;
-
-public interface INavigationResult
-{
- bool Success => Exception is null;
-
- bool Cancelled =>
- Exception is NavigationException navigationException
- && navigationException.Message == NavigationException.IConfirmNavigationReturnedFalse;
-
- Exception Exception { get; }
-}
diff --git a/src/Maui/Prism.Maui/Navigation/Internals/ChildRegionCollection.cs b/src/Maui/Prism.Maui/Navigation/Internals/ChildRegionCollection.cs
index c3e2da6132..952fb528b6 100644
--- a/src/Maui/Prism.Maui/Navigation/Internals/ChildRegionCollection.cs
+++ b/src/Maui/Prism.Maui/Navigation/Internals/ChildRegionCollection.cs
@@ -1,5 +1,5 @@
using System.Collections;
-using Prism.Regions;
+using Prism.Navigation.Regions;
namespace Prism.Navigation.Internals;
@@ -16,6 +16,7 @@ public void Add(IRegion region)
public IEnumerator GetEnumerator() =>
_regions.SelectMany(x => x.ActiveViews)
+ .OfType()
.Where(x => x is not null) // sanity check
.GetEnumerator();
diff --git a/src/Maui/Prism.Maui/Navigation/NavigationResult.cs b/src/Maui/Prism.Maui/Navigation/NavigationResult.cs
deleted file mode 100644
index e561748c49..0000000000
--- a/src/Maui/Prism.Maui/Navigation/NavigationResult.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace Prism.Navigation;
-
-public record NavigationResult : INavigationResult
-{
- public bool Success => Exception is null;
-
- public bool Cancelled =>
- Exception is NavigationException navigationException
- && navigationException.Message == NavigationException.IConfirmNavigationReturnedFalse;
-
- public Exception Exception { get; init; }
-}
diff --git a/src/Maui/Prism.Maui/Navigation/PageNavigationService.cs b/src/Maui/Prism.Maui/Navigation/PageNavigationService.cs
index 30133bf93a..87c0f29f03 100644
--- a/src/Maui/Prism.Maui/Navigation/PageNavigationService.cs
+++ b/src/Maui/Prism.Maui/Navigation/PageNavigationService.cs
@@ -1142,10 +1142,7 @@ internal static bool UseReverseNavigation(Page currentPage, Type nextPageType)
private INavigationResult Notify(NavigationRequestType type, INavigationParameters parameters, Exception exception = null)
{
- var result = new NavigationResult
- {
- Exception = exception
- };
+ var result = new NavigationResult(exception);
_eventAggregator.GetEvent().Publish(new NavigationRequestContext
{
Parameters = parameters,
@@ -1158,10 +1155,7 @@ private INavigationResult Notify(NavigationRequestType type, INavigationParamete
private INavigationResult Notify(Uri uri, INavigationParameters parameters, Exception exception = null)
{
- var result = new NavigationResult
- {
- Exception = exception
- };
+ var result = new NavigationResult(exception);
var temp = Regex.Replace(uri.ToString(), RemovePageInstruction, RemovePageRelativePath);
diff --git a/src/Maui/Prism.Maui/Regions/Adapters/CarouselViewRegionAdapter.cs b/src/Maui/Prism.Maui/Navigation/Regions/Adapters/CarouselViewRegionAdapter.cs
similarity index 95%
rename from src/Maui/Prism.Maui/Regions/Adapters/CarouselViewRegionAdapter.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/Adapters/CarouselViewRegionAdapter.cs
index 4eea8ecfef..f224413efe 100644
--- a/src/Maui/Prism.Maui/Regions/Adapters/CarouselViewRegionAdapter.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/Adapters/CarouselViewRegionAdapter.cs
@@ -4,10 +4,8 @@
using Prism.Ioc;
using Prism.Mvvm;
using Prism.Properties;
-using Prism.Regions.Behaviors;
-using Prism.Regions.Navigation;
-namespace Prism.Regions.Adapters;
+namespace Prism.Navigation.Regions.Adapters;
///
/// Adapter that creates a new and monitors its
@@ -47,7 +45,7 @@ protected override void Adapt(IRegion region, CarouselView regionTarget)
region.ActiveViews.CollectionChanged += delegate
{
- var activeView = region.ActiveViews.FirstOrDefault();
+ var activeView = region.ActiveViews.OfType().FirstOrDefault();
regionBehavior.CurrentView = activeView;
regionTarget.CurrentItem = activeView;
};
@@ -114,7 +112,7 @@ private void OnCurrentItemChanged(object sender, CurrentItemChangedEventArgs e)
}
var name = newActiveView.GetValue(ViewModelLocator.NavigationNameProperty) as string;
- if(string.IsNullOrEmpty(name))
+ if (string.IsNullOrEmpty(name))
{
var viewType = newActiveView.GetType();
var registry = _region.Container().Resolve();
diff --git a/src/Maui/Prism.Maui/Regions/Adapters/CollectionViewRegionAdapter.cs b/src/Maui/Prism.Maui/Navigation/Regions/Adapters/CollectionViewRegionAdapter.cs
similarity index 96%
rename from src/Maui/Prism.Maui/Regions/Adapters/CollectionViewRegionAdapter.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/Adapters/CollectionViewRegionAdapter.cs
index 17659fec83..334342ab72 100644
--- a/src/Maui/Prism.Maui/Regions/Adapters/CollectionViewRegionAdapter.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/Adapters/CollectionViewRegionAdapter.cs
@@ -1,8 +1,7 @@
using Prism.Ioc;
using Prism.Properties;
-using Prism.Regions.Behaviors;
-namespace Prism.Regions.Adapters;
+namespace Prism.Navigation.Regions.Adapters;
///
/// Adapter that creates a new and monitors its
diff --git a/src/Maui/Prism.Maui/Regions/Adapters/ContentViewRegionAdapter.cs b/src/Maui/Prism.Maui/Navigation/Regions/Adapters/ContentViewRegionAdapter.cs
similarity index 88%
rename from src/Maui/Prism.Maui/Regions/Adapters/ContentViewRegionAdapter.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/Adapters/ContentViewRegionAdapter.cs
index 5b110f0049..2aa73775ea 100644
--- a/src/Maui/Prism.Maui/Regions/Adapters/ContentViewRegionAdapter.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/Adapters/ContentViewRegionAdapter.cs
@@ -1,7 +1,4 @@
-using Prism.Ioc;
-using Prism.Regions.Behaviors;
-
-namespace Prism.Regions.Adapters;
+namespace Prism.Navigation.Regions.Adapters;
///
/// Adapter that creates a new and monitors its
diff --git a/src/Maui/Prism.Maui/Regions/Adapters/ContentViewRegionAdapter{TContentView}.cs b/src/Maui/Prism.Maui/Navigation/Regions/Adapters/ContentViewRegionAdapter{TContentView}.cs
similarity index 97%
rename from src/Maui/Prism.Maui/Regions/Adapters/ContentViewRegionAdapter{TContentView}.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/Adapters/ContentViewRegionAdapter{TContentView}.cs
index 45b6aa7a6c..3ba29e628f 100644
--- a/src/Maui/Prism.Maui/Regions/Adapters/ContentViewRegionAdapter{TContentView}.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/Adapters/ContentViewRegionAdapter{TContentView}.cs
@@ -1,9 +1,8 @@
using System.Collections.Specialized;
using Prism.Ioc;
using Prism.Properties;
-using Prism.Regions.Behaviors;
-namespace Prism.Regions.Adapters;
+namespace Prism.Navigation.Regions.Adapters;
///
/// Adapter that creates a new and monitors its
diff --git a/src/Maui/Prism.Maui/Regions/Adapters/IRegionAdapter.cs b/src/Maui/Prism.Maui/Navigation/Regions/Adapters/IRegionAdapter.cs
similarity index 92%
rename from src/Maui/Prism.Maui/Regions/Adapters/IRegionAdapter.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/Adapters/IRegionAdapter.cs
index 8759ea4c7e..e32c3dc7d6 100644
--- a/src/Maui/Prism.Maui/Regions/Adapters/IRegionAdapter.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/Adapters/IRegionAdapter.cs
@@ -1,4 +1,4 @@
-namespace Prism.Regions.Adapters;
+namespace Prism.Navigation.Regions.Adapters;
///
/// Defines an interfaces to adapt an object and bind it to a new .
diff --git a/src/Maui/Prism.Maui/Regions/Adapters/LayoutViewRegionAdapter.cs b/src/Maui/Prism.Maui/Navigation/Regions/Adapters/LayoutViewRegionAdapter.cs
similarity index 96%
rename from src/Maui/Prism.Maui/Regions/Adapters/LayoutViewRegionAdapter.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/Adapters/LayoutViewRegionAdapter.cs
index d5cb11f18f..07f48a0f93 100644
--- a/src/Maui/Prism.Maui/Regions/Adapters/LayoutViewRegionAdapter.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/Adapters/LayoutViewRegionAdapter.cs
@@ -1,9 +1,8 @@
using Microsoft.Maui.Controls.Compatibility;
using Prism.Ioc;
using Prism.Properties;
-using Prism.Regions.Behaviors;
-namespace Prism.Regions.Adapters;
+namespace Prism.Navigation.Regions.Adapters;
///
/// Adapter that creates a new and monitors its
diff --git a/src/Maui/Prism.Maui/Regions/Adapters/RegionAdapterBase.cs b/src/Maui/Prism.Maui/Navigation/Regions/Adapters/RegionAdapterBase.cs
similarity index 98%
rename from src/Maui/Prism.Maui/Regions/Adapters/RegionAdapterBase.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/Adapters/RegionAdapterBase.cs
index 9bd9bf9957..c803e66cc4 100644
--- a/src/Maui/Prism.Maui/Regions/Adapters/RegionAdapterBase.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/Adapters/RegionAdapterBase.cs
@@ -1,12 +1,11 @@
using System.Globalization;
using Prism.Extensions;
using Prism.Ioc;
+using Prism.Navigation.Regions.Behaviors;
using Prism.Navigation.Xaml;
using Prism.Properties;
-using Prism.Regions.Behaviors;
-using XamlNavigation = Prism.Navigation.Xaml.Navigation;
-namespace Prism.Regions.Adapters;
+namespace Prism.Navigation.Regions.Adapters;
///
/// Base class to facilitate the creation of implementations.
diff --git a/src/Maui/Prism.Maui/Regions/Adapters/RegionAdapterMappings.cs b/src/Maui/Prism.Maui/Navigation/Regions/Adapters/RegionAdapterMappings.cs
similarity index 99%
rename from src/Maui/Prism.Maui/Regions/Adapters/RegionAdapterMappings.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/Adapters/RegionAdapterMappings.cs
index 404a069d07..41e1953e73 100644
--- a/src/Maui/Prism.Maui/Regions/Adapters/RegionAdapterMappings.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/Adapters/RegionAdapterMappings.cs
@@ -2,7 +2,7 @@
using Prism.Ioc;
using Prism.Properties;
-namespace Prism.Regions.Adapters;
+namespace Prism.Navigation.Regions.Adapters;
///
/// This class maps with .
diff --git a/src/Maui/Prism.Maui/Regions/Adapters/RegionItemsSourceTemplate.cs b/src/Maui/Prism.Maui/Navigation/Regions/Adapters/RegionItemsSourceTemplate.cs
similarity index 92%
rename from src/Maui/Prism.Maui/Regions/Adapters/RegionItemsSourceTemplate.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/Adapters/RegionItemsSourceTemplate.cs
index fb1875a6c3..50d6651658 100644
--- a/src/Maui/Prism.Maui/Regions/Adapters/RegionItemsSourceTemplate.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/Adapters/RegionItemsSourceTemplate.cs
@@ -1,4 +1,4 @@
-namespace Prism.Regions.Adapters;
+namespace Prism.Navigation.Regions.Adapters;
// Implementation Note:
// In discussing with PureWeen, it is best to provide a ContentView and provide a
diff --git a/src/Maui/Prism.Maui/Regions/Adapters/ScrollViewRegionAdapter.cs b/src/Maui/Prism.Maui/Navigation/Regions/Adapters/ScrollViewRegionAdapter.cs
similarity index 96%
rename from src/Maui/Prism.Maui/Regions/Adapters/ScrollViewRegionAdapter.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/Adapters/ScrollViewRegionAdapter.cs
index f37c258f1d..53a58f95e3 100644
--- a/src/Maui/Prism.Maui/Regions/Adapters/ScrollViewRegionAdapter.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/Adapters/ScrollViewRegionAdapter.cs
@@ -1,9 +1,8 @@
using System.Collections.Specialized;
using Prism.Ioc;
using Prism.Properties;
-using Prism.Regions.Behaviors;
-namespace Prism.Regions.Adapters;
+namespace Prism.Navigation.Regions.Adapters;
///
/// Adapter that creates a new and monitors its
@@ -57,4 +56,4 @@ protected override void Adapt(IRegion region, ScrollView regionTarget)
/// A new instance of .
protected override IRegion CreateRegion(IContainerProvider container) =>
container.Resolve();
-}
\ No newline at end of file
+}
diff --git a/src/Maui/Prism.Maui/Regions/AllActiveRegion.cs b/src/Maui/Prism.Maui/Navigation/Regions/AllActiveRegion.cs
similarity index 80%
rename from src/Maui/Prism.Maui/Regions/AllActiveRegion.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/AllActiveRegion.cs
index e93b79180e..aa3d4bdce3 100644
--- a/src/Maui/Prism.Maui/Regions/AllActiveRegion.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/AllActiveRegion.cs
@@ -1,14 +1,17 @@
using Prism.Properties;
-using Prism.Regions.Navigation;
-namespace Prism.Regions;
+namespace Prism.Navigation.Regions;
///
/// Region that keeps all the views in it as active. Deactivation of views is not allowed.
///
public class AllActiveRegion : Region
{
- public AllActiveRegion(IRegionNavigationService regionNavigationService)
+ ///
+ /// Creates a new .
+ ///
+ ///
+ public AllActiveRegion(IRegionNavigationService regionNavigationService)
: base(regionNavigationService)
{
}
@@ -24,7 +27,7 @@ public AllActiveRegion(IRegionNavigationService regionNavigationService)
///
/// The view to deactivate.
/// Every time this method is called.
- public override void Deactivate(VisualElement view)
+ public override void Deactivate(object view)
{
throw new InvalidOperationException(Resources.DeactiveNotPossibleException);
}
diff --git a/src/Maui/Prism.Maui/Regions/Behaviors/AutoPopulateRegionBehavior.cs b/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/AutoPopulateRegionBehavior.cs
similarity index 96%
rename from src/Maui/Prism.Maui/Regions/Behaviors/AutoPopulateRegionBehavior.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/Behaviors/AutoPopulateRegionBehavior.cs
index 7f21f945f2..5f2b4397a8 100644
--- a/src/Maui/Prism.Maui/Regions/Behaviors/AutoPopulateRegionBehavior.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/AutoPopulateRegionBehavior.cs
@@ -1,7 +1,7 @@
using System.ComponentModel;
using Prism.Ioc;
-namespace Prism.Regions.Behaviors;
+namespace Prism.Navigation.Regions.Behaviors;
///
/// Populates the target region with the views registered to it in the .
@@ -54,12 +54,12 @@ private void StartPopulatingContent()
Region.Add(targetName);
else if (defaultView is VisualElement element)
Region.Add(element);
- else if(defaultView is Type type)
+ else if (defaultView is Type type)
{
var container = targetAware.Container;
var registry = container.Resolve();
var registration = registry.Registrations.FirstOrDefault(x => x.View == type);
- if(registration is not null)
+ if (registration is not null)
{
var view = registry.CreateView(container, registration.Name) as VisualElement;
Region.Add(view);
diff --git a/src/Maui/Prism.Maui/Regions/Behaviors/BindRegionContextToVisualElementBehavior.cs b/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/BindRegionContextToVisualElementBehavior.cs
similarity index 97%
rename from src/Maui/Prism.Maui/Regions/Behaviors/BindRegionContextToVisualElementBehavior.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/Behaviors/BindRegionContextToVisualElementBehavior.cs
index 808bdd6589..ba8aa841d7 100644
--- a/src/Maui/Prism.Maui/Regions/Behaviors/BindRegionContextToVisualElementBehavior.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/BindRegionContextToVisualElementBehavior.cs
@@ -3,10 +3,10 @@
using System.ComponentModel;
using Prism.Common;
-namespace Prism.Regions.Behaviors;
+namespace Prism.Navigation.Regions.Behaviors;
///
-/// Defines a behavior that forwards the
+/// Defines a behavior that forwards the
/// to the views in the region.
///
public class BindRegionContextToVisualElementBehavior : IRegionBehavior
diff --git a/src/Maui/Prism.Maui/Regions/Behaviors/ClearChildViewsRegionBehavior.cs b/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/ClearChildViewsRegionBehavior.cs
similarity index 86%
rename from src/Maui/Prism.Maui/Regions/Behaviors/ClearChildViewsRegionBehavior.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/Behaviors/ClearChildViewsRegionBehavior.cs
index b8077465ad..1e1c934c38 100644
--- a/src/Maui/Prism.Maui/Regions/Behaviors/ClearChildViewsRegionBehavior.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/ClearChildViewsRegionBehavior.cs
@@ -1,4 +1,4 @@
-namespace Prism.Regions.Behaviors;
+namespace Prism.Navigation.Regions.Behaviors;
///
/// Behavior that removes the RegionManager attached property of all the views in a region once the RegionManager property of a region becomes null.
@@ -31,7 +31,7 @@ public static bool GetClearChildViews(BindableObject target)
if (target == null)
throw new ArgumentNullException(nameof(target));
- return (bool)target.GetValue(ClearChildViewsRegionBehavior.ClearChildViewsProperty);
+ return (bool)target.GetValue(ClearChildViewsProperty);
}
///
@@ -44,7 +44,7 @@ public static void SetClearChildViews(BindableObject target, bool value)
if (target == null)
throw new ArgumentNullException(nameof(target));
- target.SetValue(ClearChildViewsRegionBehavior.ClearChildViewsProperty, value);
+ target.SetValue(ClearChildViewsProperty, value);
}
///
@@ -52,12 +52,12 @@ public static void SetClearChildViews(BindableObject target, bool value)
///
protected override void OnAttach()
{
- this.Region.PropertyChanged += Region_PropertyChanged;
+ Region.PropertyChanged += Region_PropertyChanged;
}
private static void ClearChildViews(IRegion region)
{
- foreach (var view in region.Views)
+ foreach (var view in region.Views.OfType())
{
if (GetClearChildViews(view))
{
@@ -70,9 +70,9 @@ private void Region_PropertyChanged(object sender, System.ComponentModel.Propert
{
if (e.PropertyName == "RegionManager")
{
- if (this.Region.RegionManager == null)
+ if (Region.RegionManager == null)
{
- ClearChildViews(this.Region);
+ ClearChildViews(Region);
}
}
}
diff --git a/src/Maui/Prism.Maui/Regions/Behaviors/DelayedRegionCreationBehavior.cs b/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/DelayedRegionCreationBehavior.cs
similarity index 96%
rename from src/Maui/Prism.Maui/Regions/Behaviors/DelayedRegionCreationBehavior.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/Behaviors/DelayedRegionCreationBehavior.cs
index 1d99e0f6d0..a70aba6ee6 100644
--- a/src/Maui/Prism.Maui/Regions/Behaviors/DelayedRegionCreationBehavior.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/DelayedRegionCreationBehavior.cs
@@ -2,13 +2,11 @@
using System.Globalization;
using Prism.Behaviors;
using Prism.Extensions;
-using Prism.Ioc;
+using Prism.Navigation.Regions.Adapters;
using Prism.Navigation.Xaml;
using Prism.Properties;
-using Prism.Regions.Adapters;
-using XamlNavigation = Prism.Navigation.Xaml.Navigation;
-namespace Prism.Regions.Behaviors;
+namespace Prism.Navigation.Regions.Behaviors;
///
/// Behavior that creates a new , when the control that will host the (see )
@@ -85,7 +83,7 @@ public void Detach()
/// Called when the is updating it's collection.
///
/// The .
- /// The instance containing the event data.
+ /// The instance containing the event data.
public void OnUpdatingRegions(object sender, EventArgs e)
{
TryCreateRegion();
diff --git a/src/Maui/Prism.Maui/Regions/Behaviors/DestructibleRegionBehavior.cs b/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/DestructibleRegionBehavior.cs
similarity index 94%
rename from src/Maui/Prism.Maui/Regions/Behaviors/DestructibleRegionBehavior.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/Behaviors/DestructibleRegionBehavior.cs
index d785e72a93..68e3732cf3 100644
--- a/src/Maui/Prism.Maui/Regions/Behaviors/DestructibleRegionBehavior.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/DestructibleRegionBehavior.cs
@@ -1,8 +1,7 @@
using System.Collections.Specialized;
using Prism.Common;
-using Prism.Navigation;
-namespace Prism.Regions.Behaviors;
+namespace Prism.Navigation.Regions.Behaviors;
///
/// Provides a Behavior to Destroy the View/ViewModel when the View is removed from the Region's Views
diff --git a/src/Maui/Prism.Maui/Regions/Behaviors/IHostAwareRegionBehavior.cs b/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/IHostAwareRegionBehavior.cs
similarity index 92%
rename from src/Maui/Prism.Maui/Regions/Behaviors/IHostAwareRegionBehavior.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/Behaviors/IHostAwareRegionBehavior.cs
index 4cd576c7ae..d55a38cd8c 100644
--- a/src/Maui/Prism.Maui/Regions/Behaviors/IHostAwareRegionBehavior.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/IHostAwareRegionBehavior.cs
@@ -1,4 +1,4 @@
-namespace Prism.Regions.Behaviors;
+namespace Prism.Navigation.Regions.Behaviors;
///
/// Defines a that not allows extensible behaviors on regions which also interact
diff --git a/src/Maui/Prism.Maui/Regions/Behaviors/RegionActiveAwareBehavior.cs b/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/RegionActiveAwareBehavior.cs
similarity index 84%
rename from src/Maui/Prism.Maui/Regions/Behaviors/RegionActiveAwareBehavior.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/Behaviors/RegionActiveAwareBehavior.cs
index 9a5ef6f31d..a61667e9b4 100644
--- a/src/Maui/Prism.Maui/Regions/Behaviors/RegionActiveAwareBehavior.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/RegionActiveAwareBehavior.cs
@@ -1,17 +1,17 @@
using System.Collections.Specialized;
using Prism.Common;
-namespace Prism.Regions.Behaviors;
+namespace Prism.Navigation.Regions.Behaviors;
///
-/// Behavior that monitors a object and
+/// Behavior that monitors a object and
/// changes the value for the property when
-/// an object that implements gets added or removed
+/// an object that implements gets added or removed
/// from the collection.
///
///
/// This class can also sync the active state for any scoped regions directly on the view based on the .
-/// If you use the method with the createRegionManagerScope option, the scoped manager will be attached to the view.
+/// If you use the method with the createRegionManagerScope option, the scoped manager will be attached to the view.
///
public class RegionActiveAwareBehavior : IRegionBehavior
{
@@ -30,7 +30,7 @@ public class RegionActiveAwareBehavior : IRegionBehavior
///
public void Attach()
{
- INotifyCollectionChanged collection = this.GetCollection();
+ INotifyCollectionChanged collection = GetCollection();
if (collection != null)
{
collection.CollectionChanged += OnCollectionChanged;
@@ -42,7 +42,7 @@ public void Attach()
///
public void Detach()
{
- INotifyCollectionChanged collection = this.GetCollection();
+ INotifyCollectionChanged collection = GetCollection();
if (collection != null)
{
collection.CollectionChanged -= OnCollectionChanged;
@@ -79,17 +79,17 @@ private void InvokeOnSynchronizedActiveAwareChildren(object item, Action e.ActiveViews);
- var syncActiveViews = activeViews.Where(ShouldSyncActiveState);
+ var syncActiveViews = activeViews.OfType().Where(ShouldSyncActiveState);
foreach (var syncActiveView in syncActiveViews)
{
@@ -112,6 +112,6 @@ private bool ShouldSyncActiveState(VisualElement view)
private INotifyCollectionChanged GetCollection()
{
- return this.Region.ActiveViews;
+ return Region.ActiveViews;
}
}
diff --git a/src/Maui/Prism.Maui/Regions/Behaviors/RegionCreationException.cs b/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/RegionCreationException.cs
similarity index 94%
rename from src/Maui/Prism.Maui/Regions/Behaviors/RegionCreationException.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/Behaviors/RegionCreationException.cs
index ee5ba2453d..54c0c3e0ee 100644
--- a/src/Maui/Prism.Maui/Regions/Behaviors/RegionCreationException.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/RegionCreationException.cs
@@ -1,9 +1,9 @@
using System.Runtime.Serialization;
-namespace Prism.Regions.Behaviors;
+namespace Prism.Navigation.Regions.Behaviors;
///
-/// Represents errors that occured during region creation.
+/// Represents errors that occurred during region creation.
///
[Serializable]
public partial class RegionCreationException : Exception
@@ -45,4 +45,4 @@ protected RegionCreationException(SerializationInfo info, StreamingContext conte
: base(info, context)
{
}
-}
\ No newline at end of file
+}
diff --git a/src/Maui/Prism.Maui/Regions/Behaviors/RegionManagerRegistrationBehavior.cs b/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/RegionManagerRegistrationBehavior.cs
similarity index 95%
rename from src/Maui/Prism.Maui/Regions/Behaviors/RegionManagerRegistrationBehavior.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/Behaviors/RegionManagerRegistrationBehavior.cs
index 94631f2948..b7e71ae275 100644
--- a/src/Maui/Prism.Maui/Regions/Behaviors/RegionManagerRegistrationBehavior.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/RegionManagerRegistrationBehavior.cs
@@ -1,7 +1,7 @@
using System.ComponentModel;
using Prism.Properties;
-namespace Prism.Regions.Behaviors;
+namespace Prism.Navigation.Regions.Behaviors;
///
/// Subscribes to a static event from the in order to register the target
@@ -107,7 +107,7 @@ private void TryRegisterRegion()
}
///
- /// This event handler gets called when a RegionManager is requering the instances of a region to be registered if they are not already.
+ /// This event handler gets called when a RegionManager is requiring the instances of a region to be registered if they are not already.
/// Although this is a public method to support Weak Delegates in Silverlight, it should not be called by the user.
///
/// The sender.
@@ -121,10 +121,10 @@ private IRegionManager FindRegionManager(Element element)
{
if (element is VisualElement visualElement)
{
- var regionmanager = RegionManagerAccessor.GetRegionManager(visualElement);
- if (regionmanager != null)
+ var regionManager = RegionManagerAccessor.GetRegionManager(visualElement);
+ if (regionManager != null)
{
- return regionmanager;
+ return regionManager;
}
}
diff --git a/src/Maui/Prism.Maui/Regions/Behaviors/RegionMemberLifetimeBehavior.cs b/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/RegionMemberLifetimeBehavior.cs
similarity index 97%
rename from src/Maui/Prism.Maui/Regions/Behaviors/RegionMemberLifetimeBehavior.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/Behaviors/RegionMemberLifetimeBehavior.cs
index b5e9a33231..61f8d53a79 100644
--- a/src/Maui/Prism.Maui/Regions/Behaviors/RegionMemberLifetimeBehavior.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/RegionMemberLifetimeBehavior.cs
@@ -1,7 +1,7 @@
using System.Collections.Specialized;
using Prism.Common;
-namespace Prism.Regions.Behaviors;
+namespace Prism.Navigation.Regions.Behaviors;
///
/// The RegionMemberLifetimeBehavior determines if items should be removed from the
@@ -9,10 +9,10 @@ namespace Prism.Regions.Behaviors;
///
///
/// The monitors the
-/// collection to discover items that transition into a deactivated state.
+/// collection to discover items that transition into a deactivated state.
///
/// The behavior checks the removed items for either the
-/// or the (in that order) to determine if it should be kept
+/// or the (in that order) to determine if it should be kept
/// alive on removal.
///
/// If the item in the collection is a , it will
diff --git a/src/Maui/Prism.Maui/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs b/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs
similarity index 92%
rename from src/Maui/Prism.Maui/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs
index 430d3615b1..965657d38b 100644
--- a/src/Maui/Prism.Maui/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs
@@ -1,14 +1,14 @@
using Prism.Common;
using Prism.Properties;
-namespace Prism.Regions.Behaviors;
+namespace Prism.Navigation.Regions.Behaviors;
///
-/// Behavior that synchronizes the property of a with
-/// the control that hosts the Region. It does this by setting the
+/// Behavior that synchronizes the property of a with
+/// the control that hosts the Region. It does this by setting the
/// Dependency Property on the host control.
-///
-/// This behavior allows the usage of two way databinding of the RegionContext from XAML.
+///
+/// This behavior allows the usage of two way databinding of the RegionContext from XAML.
///
public class SyncRegionContextWithHostBehavior : RegionBehavior, IHostAwareRegionBehavior
{
@@ -16,7 +16,7 @@ public class SyncRegionContextWithHostBehavior : RegionBehavior, IHostAwareRegio
private VisualElement _hostControl;
///
- /// Name that identifies the SyncRegionContextWithHostBehavior behavior in a collection of RegionsBehaviors.
+ /// Name that identifies the SyncRegionContextWithHostBehavior behavior in a collection of RegionsBehaviors.
///
public static readonly string BehaviorKey = "SyncRegionContextWithHost";
@@ -52,7 +52,7 @@ protected override void OnAttach()
{
if (HostControl != null)
{
- // Sync values initially.
+ // Sync values initially.
SynchronizeRegionContext();
// Now register for events to keep them in sync
diff --git a/src/Maui/Prism.Maui/Regions/DefaultRegionManagerAccessor.cs b/src/Maui/Prism.Maui/Navigation/Regions/DefaultRegionManagerAccessor.cs
similarity index 98%
rename from src/Maui/Prism.Maui/Regions/DefaultRegionManagerAccessor.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/DefaultRegionManagerAccessor.cs
index d492ae093c..32e810ae59 100644
--- a/src/Maui/Prism.Maui/Regions/DefaultRegionManagerAccessor.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/DefaultRegionManagerAccessor.cs
@@ -1,6 +1,6 @@
using Prism.Ioc;
-namespace Prism.Regions;
+namespace Prism.Navigation.Regions;
internal class DefaultRegionManagerAccessor : IRegionManagerAccessor
{
diff --git a/src/Maui/Prism.Maui/Regions/IRegionManagerAccessor.cs b/src/Maui/Prism.Maui/Navigation/Regions/IRegionManagerAccessor.cs
similarity index 96%
rename from src/Maui/Prism.Maui/Regions/IRegionManagerAccessor.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/IRegionManagerAccessor.cs
index 3ae2eb4d63..fd5316c0fe 100644
--- a/src/Maui/Prism.Maui/Regions/IRegionManagerAccessor.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/IRegionManagerAccessor.cs
@@ -1,4 +1,4 @@
-namespace Prism.Regions;
+namespace Prism.Navigation.Regions;
///
/// Provides an abstraction on top of the RegionManager static members.
@@ -16,7 +16,7 @@ public interface IRegionManagerAccessor
/// Gets the value for the RegionName attached property.
///
/// The object to adapt. This is typically a container (i.e a control).
- /// The name of the region that should be created when
+ /// The name of the region that should be created when
/// the RegionManager is also set in this element.
string GetRegionName(VisualElement element);
diff --git a/src/Maui/Prism.Maui/Regions/IRegionMemberLifetime.cs b/src/Maui/Prism.Maui/Navigation/Regions/IRegionMemberLifetime.cs
similarity index 85%
rename from src/Maui/Prism.Maui/Regions/IRegionMemberLifetime.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/IRegionMemberLifetime.cs
index 8cf44e9f1a..3333c4a974 100644
--- a/src/Maui/Prism.Maui/Regions/IRegionMemberLifetime.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/IRegionMemberLifetime.cs
@@ -1,6 +1,6 @@
-using Prism.Regions.Behaviors;
+using Prism.Navigation.Regions.Behaviors;
-namespace Prism.Regions;
+namespace Prism.Navigation.Regions;
///
/// When implemented, allows an instance placed in a
diff --git a/src/Maui/Prism.Maui/Regions/ITargetAwareRegion.cs b/src/Maui/Prism.Maui/Navigation/Regions/ITargetAwareRegion.cs
similarity index 88%
rename from src/Maui/Prism.Maui/Regions/ITargetAwareRegion.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/ITargetAwareRegion.cs
index 4a809b6005..563a312466 100644
--- a/src/Maui/Prism.Maui/Regions/ITargetAwareRegion.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/ITargetAwareRegion.cs
@@ -2,11 +2,12 @@
using Prism.Ioc;
using Prism.Navigation.Xaml;
-namespace Prism.Regions;
+namespace Prism.Navigation.Regions;
[EditorBrowsable(EditorBrowsableState.Never)]
public interface ITargetAwareRegion : IRegion
{
VisualElement TargetElement { get; set; }
+
IContainerProvider Container => TargetElement.GetContainerProvider();
}
diff --git a/src/Maui/Prism.Maui/Regions/ItemMetadata.cs b/src/Maui/Prism.Maui/Navigation/Regions/ItemMetadata.cs
similarity index 98%
rename from src/Maui/Prism.Maui/Regions/ItemMetadata.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/ItemMetadata.cs
index 5c0b68c509..adb151bc21 100644
--- a/src/Maui/Prism.Maui/Regions/ItemMetadata.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/ItemMetadata.cs
@@ -1,4 +1,4 @@
-namespace Prism.Regions;
+namespace Prism.Navigation.Regions;
///
/// Defines a class that wraps an item and adds metadata for it.
diff --git a/src/Maui/Prism.Maui/Regions/Navigation/RegionNavigationContentLoader.cs b/src/Maui/Prism.Maui/Navigation/Regions/Navigation/RegionNavigationContentLoader.cs
similarity index 93%
rename from src/Maui/Prism.Maui/Regions/Navigation/RegionNavigationContentLoader.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/Navigation/RegionNavigationContentLoader.cs
index 12f6cf2add..8940098965 100644
--- a/src/Maui/Prism.Maui/Regions/Navigation/RegionNavigationContentLoader.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/Navigation/RegionNavigationContentLoader.cs
@@ -1,11 +1,10 @@
using System.Globalization;
using Prism.Common;
using Prism.Ioc;
-using Prism.Ioc.Internals;
using Prism.Mvvm;
using Prism.Properties;
-namespace Prism.Regions.Navigation;
+namespace Prism.Navigation.Regions.Navigation;
///
/// Implementation of that relies on a
@@ -26,7 +25,7 @@ public class RegionNavigationContentLoader : IRegionNavigationContentLoader
/// is created and added to the region.
///
/// when a new view cannot be created for the navigation request.
- public object LoadContent(IRegion region, INavigationContext navigationContext)
+ public object LoadContent(IRegion region, NavigationContext navigationContext)
{
if (region == null)
throw new ArgumentNullException(nameof(region));
@@ -88,7 +87,7 @@ protected virtual object CreateNewRegionItem(string candidateTargetContract, IRe
///
/// The navigation contract.
/// The candidate contract to seek within the and to use, if not found, when resolving from the container.
- protected virtual string GetContractFromNavigationContext(INavigationContext navigationContext)
+ protected virtual string GetContractFromNavigationContext(NavigationContext navigationContext)
{
if (navigationContext == null) throw new ArgumentNullException(nameof(navigationContext));
@@ -121,7 +120,7 @@ protected virtual IEnumerable GetCandidatesFromRegion(IRegion reg
{
var registry = region.Container().Resolve();
var registration = registry.Registrations.FirstOrDefault(x => x.Type == ViewType.Region && (x.Name == candidateNavigationContract || x.View.Name == candidateNavigationContract || x.View.FullName == candidateNavigationContract));
- if(registration is null)
+ if (registration is null)
{
GetCandidatesFromRegionViews(region, registration.View.FullName);
}
@@ -134,7 +133,7 @@ protected virtual IEnumerable GetCandidatesFromRegion(IRegion reg
private IEnumerable GetCandidatesFromRegionViews(IRegion region, string candidateNavigationContract)
{
- return region.Views.Where(v => ViewIsMatch(v.GetType(), candidateNavigationContract));
+ return region.Views.OfType().Where(v => ViewIsMatch(v.GetType(), candidateNavigationContract));
}
private static bool ViewIsMatch(Type viewType, string navigationSegment)
diff --git a/src/Maui/Prism.Maui/Regions/Navigation/RegionNavigationService.cs b/src/Maui/Prism.Maui/Navigation/Regions/Navigation/RegionNavigationService.cs
similarity index 83%
rename from src/Maui/Prism.Maui/Regions/Navigation/RegionNavigationService.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/Navigation/RegionNavigationService.cs
index 2b9c3c4a12..44d4691650 100644
--- a/src/Maui/Prism.Maui/Regions/Navigation/RegionNavigationService.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/Navigation/RegionNavigationService.cs
@@ -1,9 +1,8 @@
using Prism.Common;
using Prism.Ioc;
-using Prism.Navigation;
using Prism.Properties;
-namespace Prism.Regions.Navigation;
+namespace Prism.Navigation.Regions.Navigation;
///
/// Provides navigation for regions.
@@ -45,7 +44,7 @@ public RegionNavigationService(IContainerExtension container, IRegionNavigationC
///
public event EventHandler Navigating;
- private void RaiseNavigating(INavigationContext navigationContext)
+ private void RaiseNavigating(NavigationContext navigationContext)
{
Navigating?.Invoke(this, new RegionNavigationEventArgs(navigationContext));
}
@@ -55,7 +54,7 @@ private void RaiseNavigating(INavigationContext navigationContext)
///
public event EventHandler Navigated;
- private void RaiseNavigated(INavigationContext navigationContext)
+ private void RaiseNavigated(NavigationContext navigationContext)
{
Navigated?.Invoke(this, new RegionNavigationEventArgs(navigationContext));
}
@@ -65,7 +64,7 @@ private void RaiseNavigated(INavigationContext navigationContext)
///
public event EventHandler NavigationFailed;
- private void RaiseNavigationFailed(INavigationContext navigationContext, Exception error)
+ private void RaiseNavigationFailed(NavigationContext navigationContext, Exception error)
{
NavigationFailed?.Invoke(this, new RegionNavigationFailedEventArgs(navigationContext, error));
}
@@ -75,7 +74,7 @@ private void RaiseNavigationFailed(INavigationContext navigationContext, Excepti
///
/// The target.
/// A callback to execute when the navigation request is completed.
- public void RequestNavigate(Uri target, Action navigationCallback)
+ public void RequestNavigate(Uri target, Action navigationCallback)
{
RequestNavigate(target, navigationCallback, null);
}
@@ -86,7 +85,7 @@ public void RequestNavigate(Uri target, Action navigati
/// The target.
/// A callback to execute when the navigation request is completed.
/// The navigation parameters specific to the navigation request.
- public void RequestNavigate(Uri target, Action navigationCallback, INavigationParameters regionParameters)
+ public void RequestNavigate(Uri target, Action navigationCallback, INavigationParameters regionParameters)
{
if (navigationCallback == null)
throw new ArgumentNullException(nameof(navigationCallback));
@@ -101,7 +100,7 @@ public void RequestNavigate(Uri target, Action navigati
}
}
- private void DoNavigate(Uri source, Action navigationCallback, INavigationParameters regionParameters)
+ private void DoNavigate(Uri source, Action navigationCallback, INavigationParameters regionParameters)
{
if (source == null)
throw new ArgumentNullException(nameof(source));
@@ -115,19 +114,19 @@ private void DoNavigate(Uri source, Action navigationCa
RequestCanNavigateFromOnCurrentlyActiveView(
_currentNavigationContext,
navigationCallback,
- Region.ActiveViews.ToArray(),
+ Region.ActiveViews.OfType().ToArray(),
0);
}
private void RequestCanNavigateFromOnCurrentlyActiveView(
- INavigationContext navigationContext,
- Action navigationCallback,
+ NavigationContext navigationContext,
+ Action navigationCallback,
VisualElement[] activeViews,
int currentViewIndex)
{
if (currentViewIndex < activeViews.Length)
{
- if (activeViews[currentViewIndex] is IConfirmRegionNavigationRequest vetoingView)
+ if (activeViews[currentViewIndex] is IConfirmNavigationRequest vetoingView)
{
// the current active view implements IConfirmNavigationRequest, request confirmation
// providing a callback to resume the navigation request
@@ -165,12 +164,12 @@ private void RequestCanNavigateFromOnCurrentlyActiveView(
}
private void RequestCanNavigateFromOnCurrentlyActiveViewModel(
- INavigationContext navigationContext,
- Action navigationCallback,
+ NavigationContext navigationContext,
+ Action navigationCallback,
VisualElement[] activeViews,
int currentViewIndex)
{
- if (activeViews[currentViewIndex].BindingContext is IConfirmRegionNavigationRequest vetoingViewModel)
+ if (activeViews[currentViewIndex].BindingContext is IConfirmNavigationRequest vetoingViewModel)
{
// the data model for the current active view implements IConfirmNavigationRequest, request confirmation
// providing a callback to resume the navigation request
@@ -202,7 +201,7 @@ private void RequestCanNavigateFromOnCurrentlyActiveViewModel(
currentViewIndex + 1);
}
- private void ExecuteNavigation(INavigationContext navigationContext, object[] activeViews, Action navigationCallback)
+ private void ExecuteNavigation(NavigationContext navigationContext, object[] activeViews, Action navigationCallback)
{
try
{
@@ -227,7 +226,7 @@ private void ExecuteNavigation(INavigationContext navigationContext, object[] ac
// The view can be informed of navigation
MvvmHelpers.OnNavigatedTo(view, navigationContext);
- navigationCallback(new RegionNavigationResult(navigationContext, true));
+ navigationCallback(new NavigationResult(navigationContext, true));
// Raise the navigated event when navigation is completed.
RaiseNavigated(navigationContext);
@@ -245,20 +244,20 @@ private static bool PersistInHistory(object view)
return persist;
}
- private void NotifyNavigationFailed(INavigationContext navigationContext, Action navigationCallback, Exception e)
+ private void NotifyNavigationFailed(NavigationContext navigationContext, Action navigationCallback, Exception e)
{
var navigationResult =
- e != null ? new RegionNavigationResult(navigationContext, e) : new RegionNavigationResult(navigationContext, false);
+ e != null ? new NavigationResult(navigationContext, e) : new NavigationResult(navigationContext, false);
navigationCallback(navigationResult);
RaiseNavigationFailed(navigationContext, e);
}
- private static void NotifyActiveViewsNavigatingFrom(INavigationContext navigationContext, object[] activeViews)
+ private static void NotifyActiveViewsNavigatingFrom(NavigationContext navigationContext, object[] activeViews)
{
foreach (var item in activeViews)
{
MvvmHelpers.OnNavigatedFrom(item, navigationContext);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Maui/Prism.Maui/Regions/Region.cs b/src/Maui/Prism.Maui/Navigation/Regions/Region.cs
similarity index 88%
rename from src/Maui/Prism.Maui/Regions/Region.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/Region.cs
index 3b59d79e17..699bc946ed 100644
--- a/src/Maui/Prism.Maui/Regions/Region.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/Region.cs
@@ -4,10 +4,8 @@
using Prism.Mvvm;
using Prism.Navigation.Xaml;
using Prism.Properties;
-using Prism.Regions.Behaviors;
-using Prism.Regions.Navigation;
-namespace Prism.Regions;
+namespace Prism.Navigation.Regions;
///
/// Implementation of that allows multiple active views.
@@ -17,7 +15,7 @@ public class Region : BindableBase, IRegion, ITargetAwareRegion
private ObservableCollection _itemMetadataCollection;
private IRegionManager _regionManager;
private readonly IRegionNavigationService _regionNavigationService;
- private Comparison _sort;
+ private Comparison _sort;
///
/// Initializes a new instance of .
@@ -122,7 +120,7 @@ public string Name
/// Gets or sets the comparison used to sort the views.
///
/// The comparison to use.
- public Comparison SortComparison
+ public Comparison SortComparison
{
get => _sort;
set
@@ -162,7 +160,11 @@ public IRegionManager RegionManager
/// Gets the navigation service.
///
/// The navigation service.
- public IRegionNavigationService NavigationService => _regionNavigationService;
+ public IRegionNavigationService NavigationService
+ {
+ get => _regionNavigationService;
+ set => throw new NotImplementedException();
+ }
///
/// Gets the collection with all the views along with their metadata.
@@ -185,7 +187,7 @@ protected virtual ObservableCollection ItemMetadataCollection
/// Marks the specified view as active.
///
/// The view to activate.
- public virtual void Activate(VisualElement view)
+ public virtual void Activate(object view)
{
var itemMetadata = GetItemMetadataOrThrow(view);
@@ -199,7 +201,7 @@ public virtual void Activate(VisualElement view)
/// Marks the specified view as inactive.
///
/// The view to deactivate.
- public virtual void Deactivate(VisualElement view)
+ public virtual void Deactivate(object view)
{
var itemMetadata = GetItemMetadataOrThrow(view);
@@ -223,7 +225,7 @@ public IRegionManager Add(string viewName)
///
/// The view to add.
/// The that is set on the view if it is a . It will be the current region manager when using this overload.
- public IRegionManager Add(VisualElement view)
+ public IRegionManager Add(object view)
{
return Add(view, null, false);
}
@@ -234,7 +236,7 @@ public IRegionManager Add(VisualElement view)
/// The view to add.
/// The name of the view. This can be used to retrieve it later by calling .
/// The that is set on the view if it is a . It will be the current region manager when using this overload.
- public IRegionManager Add(VisualElement view, string viewName)
+ public IRegionManager Add(object view, string viewName)
{
if (string.IsNullOrEmpty(viewName))
{
@@ -251,21 +253,26 @@ public IRegionManager Add(VisualElement view, string viewName)
/// The name of the view. This can be used to retrieve it later by calling .
/// When , the added view will receive a new instance of , otherwise it will use the current region manager for this region.
/// The that is set on the view if it is a .
- public virtual IRegionManager Add(VisualElement view, string viewName, bool createRegionManagerScope)
+ public virtual IRegionManager Add(object view, string viewName, bool createRegionManagerScope)
{
IRegionManager manager = createRegionManagerScope ? RegionManager.CreateRegionManager() : RegionManager;
InnerAdd(view, viewName, manager);
return manager;
}
- private void InnerAdd(VisualElement view, string viewName, IRegionManager scopedRegionManager)
+ private void InnerAdd(object view, string viewName, IRegionManager scopedRegionManager)
{
+ if (view is not VisualElement visualElement)
+ {
+ throw new UpdateRegionsException("The view must inherit from VisualElement.");
+ }
+
if (ItemMetadataCollection.FirstOrDefault(x => x.Item == view) != null)
{
throw new InvalidOperationException(Resources.RegionViewExistsException);
}
- var itemMetadata = new ItemMetadata(view);
+ var itemMetadata = new ItemMetadata(visualElement);
if (!string.IsNullOrEmpty(viewName))
{
if (ItemMetadataCollection.FirstOrDefault(x => x.Name == viewName) != null)
@@ -275,7 +282,7 @@ private void InnerAdd(VisualElement view, string viewName, IRegionManager scoped
itemMetadata.Name = viewName;
}
- Xaml.RegionManager.SetRegionManager(view, scopedRegionManager);
+ Xaml.RegionManager.SetRegionManager(visualElement, scopedRegionManager);
ItemMetadataCollection.Add(itemMetadata);
}
@@ -285,7 +292,7 @@ private void InnerAdd(VisualElement view, string viewName, IRegionManager scoped
///
/// The name used when adding the view to the region.
/// Returns the named view or if the view with does not exist in the current region.
- public virtual VisualElement GetView(string viewName)
+ public virtual object GetView(string viewName)
{
if (string.IsNullOrEmpty(viewName))
{
@@ -306,15 +313,20 @@ public virtual VisualElement GetView(string viewName)
/// Removes the specified view from the region.
///
/// The view to remove.
- public void Remove(VisualElement view)
+ public void Remove(object view)
{
+ if (view is not VisualElement visualElement)
+ {
+ throw new Exception("The view must inherit from VisualElement.");
+ }
+
var itemMetadata = GetItemMetadataOrThrow(view);
ItemMetadataCollection.Remove(itemMetadata);
- if (Xaml.RegionManager.GetRegionManager(view) == RegionManager)
+ if (Xaml.RegionManager.GetRegionManager(visualElement) == RegionManager)
{
- view.ClearValue(Xaml.RegionManager.RegionManagerProperty);
+ visualElement.ClearValue(Xaml.RegionManager.RegionManagerProperty);
}
}
@@ -399,4 +411,7 @@ private static int ViewSortHintAttributeComparison(ViewSortHintAttribute x, View
}
}
}
+
+ public void RequestNavigate(Uri target, Action navigationCallback, INavigationParameters navigationParameters) =>
+ NavigationService.RequestNavigate(target, navigationCallback, navigationParameters);
}
diff --git a/src/Maui/Prism.Maui/Regions/RegionCollection.cs b/src/Maui/Prism.Maui/Navigation/Regions/RegionCollection.cs
similarity index 97%
rename from src/Maui/Prism.Maui/Regions/RegionCollection.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/RegionCollection.cs
index e5b645fabb..8d44e9be41 100644
--- a/src/Maui/Prism.Maui/Regions/RegionCollection.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/RegionCollection.cs
@@ -3,7 +3,7 @@
using System.Globalization;
using Prism.Properties;
-namespace Prism.Regions;
+namespace Prism.Navigation.Regions;
internal class RegionCollection : IRegionCollection
{
@@ -63,7 +63,7 @@ public void Add(IRegion region)
}
_regions.Add(region);
- region.RegionManager = this.regionManager;
+ region.RegionManager = regionManager;
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, region, 0));
}
diff --git a/src/Maui/Prism.Maui/Regions/RegionContext.cs b/src/Maui/Prism.Maui/Navigation/Regions/RegionContext.cs
similarity index 95%
rename from src/Maui/Prism.Maui/Regions/RegionContext.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/RegionContext.cs
index 9d9460563b..a476a67377 100644
--- a/src/Maui/Prism.Maui/Regions/RegionContext.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/RegionContext.cs
@@ -1,7 +1,7 @@
using Prism.Common;
-using Prism.Regions.Behaviors;
+using Prism.Navigation.Regions.Behaviors;
-namespace Prism.Regions;
+namespace Prism.Navigation.Regions;
///
/// Class that holds methods to Set and Get the RegionContext from a BindableObject.
diff --git a/src/Maui/Prism.Maui/Regions/RegionExtensions.cs b/src/Maui/Prism.Maui/Navigation/Regions/RegionExtensions.cs
similarity index 90%
rename from src/Maui/Prism.Maui/Regions/RegionExtensions.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/RegionExtensions.cs
index 7160585673..a29b3f4130 100644
--- a/src/Maui/Prism.Maui/Regions/RegionExtensions.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/RegionExtensions.cs
@@ -1,6 +1,6 @@
using Prism.Ioc;
-namespace Prism.Regions;
+namespace Prism.Navigation.Regions;
internal static class RegionExtensions
{
diff --git a/src/Maui/Prism.Maui/Regions/RegionManager.cs b/src/Maui/Prism.Maui/Navigation/Regions/RegionManager.cs
similarity index 77%
rename from src/Maui/Prism.Maui/Regions/RegionManager.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/RegionManager.cs
index e89a2ce7dc..2abb34282c 100644
--- a/src/Maui/Prism.Maui/Regions/RegionManager.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/RegionManager.cs
@@ -1,10 +1,7 @@
using Prism.Ioc;
-using Prism.Ioc.Internals;
-using Prism.Navigation;
using Prism.Properties;
-using Prism.Regions.Navigation;
-namespace Prism.Regions;
+namespace Prism.Navigation.Regions;
///
/// This class is responsible for maintaining a collection of regions and attaching regions to controls.
@@ -43,6 +40,20 @@ public IRegionManager AddToRegion(string regionName, string targetName)
return region.Add(targetName);
}
+ ///
+ /// Add a view to the Views collection of a Region. Note that the region must already exist in this .
+ ///
+ /// The name of the region to add a view to
+ /// The view to add to the views collection
+ /// The RegionManager, to easily add several views.
+ public IRegionManager AddToRegion(string regionName, object view)
+ {
+ if (!Regions.ContainsRegionWithName(regionName))
+ throw new ArgumentException(string.Format(Thread.CurrentThread.CurrentCulture, Resources.RegionNotFound, regionName), nameof(regionName));
+
+ return Regions[regionName].Add(view);
+ }
+
///
/// Creates a new region manager.
///
@@ -80,13 +91,30 @@ public IRegionManager RegisterViewWithRegion(string regionName, string targetNam
return this;
}
+ ///
+ /// Associate a view with a region, using a delegate to resolve a concrete instance of the view.
+ /// When the region get's displayed, this delegate will be called and the result will be added to the
+ /// views collection of the region.
+ ///
+ /// The name of the region to associate the view with.
+ /// The delegate used to resolve a concrete instance of the view.
+ /// The , for adding several views easily
+ public IRegionManager RegisterViewWithRegion(string regionName, Func getContentDelegate)
+ {
+ var regionViewRegistry = ContainerLocator.Container.Resolve();
+
+ regionViewRegistry.RegisterViewWithRegion(regionName, getContentDelegate);
+
+ return this;
+ }
+
///
/// Navigates the specified region manager.
///
/// The name of the region to call Navigate on.
/// The URI of the content to display.
/// The navigation callback.
- public void RequestNavigate(string regionName, Uri target, Action navigationCallback) =>
+ public void RequestNavigate(string regionName, Uri target, Action navigationCallback) =>
RequestNavigate(regionName, target, navigationCallback, null);
///
@@ -96,7 +124,7 @@ public void RequestNavigate(string regionName, Uri target, ActionA that represents the target where the region will navigate.
/// The navigation callback that will be executed after the navigation is completed.
/// An instance of , which holds a collection of object parameters.
- public void RequestNavigate(string regionName, Uri target, Action navigationCallback, INavigationParameters navigationParameters)
+ public void RequestNavigate(string regionName, Uri target, Action navigationCallback, INavigationParameters navigationParameters)
{
try
{
@@ -113,7 +141,7 @@ public void RequestNavigate(string regionName, Uri target, Action
/// Defines a registry for the content of the regions used on View Discovery composition.
///
public class RegionViewRegistry : IRegionViewRegistry
{
- private readonly ListDictionary> _registeredContent = new ();
- private readonly WeakDelegatesManager _contentRegisteredListeners = new ();
+ private readonly ListDictionary> _registeredContent = new();
+ private readonly WeakDelegatesManager _contentRegisteredListeners = new();
///
/// Occurs whenever a new view is registered.
@@ -28,6 +28,7 @@ public event EventHandler ContentRegistered
///
/// Returns the contents registered for a region.
///
+ /// The to use.
/// Name of the region which content is being requested.
/// Collection of contents registered for the region.
public IEnumerable GetContents(string regionName, IContainerProvider container)
@@ -74,7 +75,7 @@ public void RegisterViewWithRegion(string regionName, string targetName)
}
///
- /// Registers a delegate that can be used to retrieve the content associated with a region name.
+ /// Registers a delegate that can be used to retrieve the content associated with a region name.
///
/// Region name to which the will be registered.
/// Delegate used to retrieve the content associated with the .
diff --git a/src/Maui/Prism.Maui/Regions/SingleActiveRegion.cs b/src/Maui/Prism.Maui/Navigation/Regions/SingleActiveRegion.cs
similarity index 77%
rename from src/Maui/Prism.Maui/Regions/SingleActiveRegion.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/SingleActiveRegion.cs
index 6f19becc97..48c58000cb 100644
--- a/src/Maui/Prism.Maui/Regions/SingleActiveRegion.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/SingleActiveRegion.cs
@@ -1,12 +1,14 @@
-using Prism.Regions.Navigation;
-
-namespace Prism.Regions;
+namespace Prism.Navigation.Regions;
///
/// Region that allows a maximum of one active view at a time.
///
public class SingleActiveRegion : Region
{
+ ///
+ /// Creates a new .
+ ///
+ ///
public SingleActiveRegion(IRegionNavigationService regionNavigationService)
: base(regionNavigationService)
{
@@ -18,7 +20,7 @@ public SingleActiveRegion(IRegionNavigationService regionNavigationService)
/// The view to activate.
/// If there is an active view before calling this method,
/// that view will be deactivated automatically.
- public override void Activate(VisualElement view)
+ public override void Activate(object view)
{
var currentActiveView = ActiveViews.FirstOrDefault();
diff --git a/src/Maui/Prism.Maui/Regions/ViewsCollection.cs b/src/Maui/Prism.Maui/Navigation/Regions/ViewsCollection.cs
similarity index 89%
rename from src/Maui/Prism.Maui/Regions/ViewsCollection.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/ViewsCollection.cs
index d0e4931e51..0d14847bca 100644
--- a/src/Maui/Prism.Maui/Regions/ViewsCollection.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/ViewsCollection.cs
@@ -3,7 +3,7 @@
using System.Collections.Specialized;
using Prism.Mvvm;
-namespace Prism.Regions;
+namespace Prism.Navigation.Regions;
///
/// Implementation of that takes an of
@@ -15,7 +15,7 @@ public class ViewsCollection : BindableBase, IViewsCollection
private readonly ObservableCollection _subjectCollection;
private readonly Dictionary _monitoredItems = new Dictionary();
- private Comparison _sort;
+ private Comparison _sort;
private List filteredItems = new List();
///
@@ -41,7 +41,7 @@ public ViewsCollection(ObservableCollection list, Predicate
/// The comparison to use.
- public Comparison SortComparison
+ public Comparison SortComparison
{
get => _sort;
set => SetProperty(ref _sort, value, () =>
@@ -61,7 +61,7 @@ public Comparison SortComparison
///
/// The object to locate in the collection.
/// if is found in the collection; otherwise, .
- public bool Contains(VisualElement value) => filteredItems.Contains(value);
+ public bool Contains(object value) => filteredItems.Contains(value);
///
///Returns an enumerator that iterates through the collection.
@@ -69,7 +69,7 @@ public Comparison SortComparison
///
///A that can be used to iterate through the collection.
///
- public IEnumerator GetEnumerator() => filteredItems.GetEnumerator();
+ public IEnumerator GetEnumerator() => filteredItems.GetEnumerator();
///
///Returns an enumerator that iterates through a collection.
@@ -79,7 +79,7 @@ public Comparison SortComparison
///
IEnumerator IEnumerable.GetEnumerator()
{
- return this.GetEnumerator();
+ return GetEnumerator();
}
///
@@ -121,12 +121,12 @@ private void MonitorAllMetadataItems()
///
private void RemoveAllMetadataMonitors()
{
- foreach (var item in this._monitoredItems)
+ foreach (var item in _monitoredItems)
{
- item.Key.MetadataChanged -= this.OnItemMetadataChanged;
+ item.Key.MetadataChanged -= OnItemMetadataChanged;
}
- this._monitoredItems.Clear();
+ _monitoredItems.Clear();
}
///
@@ -170,7 +170,7 @@ private void OnItemMetadataChanged(object sender, EventArgs e)
bool foundInfo = _monitoredItems.TryGetValue(itemMetadata, out MonitorInfo monitorInfo);
if (!foundInfo) return;
- if (this.Filter(itemMetadata))
+ if (Filter(itemMetadata))
{
if (!monitorInfo.IsInList)
{
@@ -178,7 +178,7 @@ private void OnItemMetadataChanged(object sender, EventArgs e)
// as in our list so we can consider this
// an Add.
monitorInfo.IsInList = true;
- this.UpdateFilteredItemsList();
+ UpdateFilteredItemsList();
NotifyAdd(itemMetadata.Item);
}
}
@@ -188,7 +188,7 @@ private void OnItemMetadataChanged(object sender, EventArgs e)
// tracking list, but should not remove any monitoring in
// case it fits our filter in the future.
monitorInfo.IsInList = false;
- this.RemoveFromFilteredList(itemMetadata.Item);
+ RemoveFromFilteredList(itemMetadata.Item);
}
}
@@ -214,11 +214,11 @@ private void SourceCollectionChanged(object sender, NotifyCollectionChangedEvent
}
// If we're sorting we can't predict how
- // the collection has changed on an add so we
+ // the collection has changed on an add so we
// resort to a reset notification.
if (SortComparison != null)
{
- this.NotifyReset();
+ NotifyReset();
}
break;
@@ -226,19 +226,19 @@ private void SourceCollectionChanged(object sender, NotifyCollectionChangedEvent
case NotifyCollectionChangedAction.Remove:
foreach (ItemMetadata itemMetadata in e.OldItems)
{
- this.RemoveMetadataMonitor(itemMetadata);
- if (this.Filter(itemMetadata))
+ RemoveMetadataMonitor(itemMetadata);
+ if (Filter(itemMetadata))
{
- this.RemoveFromFilteredList(itemMetadata.Item);
+ RemoveFromFilteredList(itemMetadata.Item);
}
}
break;
default:
- this.ResetAllMonitors();
- this.UpdateFilteredItemsList();
- this.NotifyReset();
+ ResetAllMonitors();
+ UpdateFilteredItemsList();
+ NotifyReset();
break;
}
@@ -279,12 +279,12 @@ public RegionItemComparer(Comparison comparer)
public override int Compare(VisualElement x, VisualElement y)
{
- if (this.comparer == null)
+ if (comparer == null)
{
return 0;
}
- return this.comparer(x, y);
+ return comparer(x, y);
}
}
diff --git a/src/Maui/Prism.Maui/Regions/Xaml/RegionManager.cs b/src/Maui/Prism.Maui/Navigation/Regions/Xaml/RegionManager.cs
similarity index 97%
rename from src/Maui/Prism.Maui/Regions/Xaml/RegionManager.cs
rename to src/Maui/Prism.Maui/Navigation/Regions/Xaml/RegionManager.cs
index 7ef770e2c6..7675c562f2 100644
--- a/src/Maui/Prism.Maui/Regions/Xaml/RegionManager.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/Xaml/RegionManager.cs
@@ -1,15 +1,13 @@
-using System.ComponentModel;
-using System.Globalization;
+using System.Globalization;
using System.Reflection;
using Prism.Common;
using Prism.Events;
-using Prism.Extensions;
using Prism.Ioc;
+using Prism.Navigation.Regions.Adapters;
+using Prism.Navigation.Regions.Behaviors;
using Prism.Properties;
-using Prism.Regions.Adapters;
-using Prism.Regions.Behaviors;
-namespace Prism.Regions.Xaml;
+namespace Prism.Navigation.Regions.Xaml;
///
/// A class to provide Bindable Properties and helpers for Regions.
@@ -58,7 +56,7 @@ public static class RegionManager
public static readonly BindableProperty DefaultViewProperty =
BindableProperty.CreateAttached("DefaultView", typeof(object), typeof(RegionManager), null);
- public static void SetDefaultView(VisualElement regionTarget, object viewNameTypeOrInstance) =>
+ public static void SetDefaultView(VisualElement regionTarget, object viewNameTypeOrInstance) =>
regionTarget.SetValue(DefaultViewProperty, viewNameTypeOrInstance);
public static object GetDefaultView(VisualElement regionTarget) =>
diff --git a/src/Maui/Prism.Maui/Navigation/Xaml/GoBackExtension.cs b/src/Maui/Prism.Maui/Navigation/Xaml/GoBackExtension.cs
index 0ba9073016..8da35f53f8 100644
--- a/src/Maui/Prism.Maui/Navigation/Xaml/GoBackExtension.cs
+++ b/src/Maui/Prism.Maui/Navigation/Xaml/GoBackExtension.cs
@@ -29,4 +29,4 @@ await navigationService.GoBackToRootAsync(parameters) :
Log(result.Exception, parameters);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Maui/Prism.Maui/Prism.Maui.csproj b/src/Maui/Prism.Maui/Prism.Maui.csproj
index 1e5b20ded5..bc9b7536c3 100644
--- a/src/Maui/Prism.Maui/Prism.Maui.csproj
+++ b/src/Maui/Prism.Maui/Prism.Maui.csproj
@@ -21,7 +21,6 @@
- TrueTrue
diff --git a/src/Maui/Prism.Maui/PrismAppBuilder.cs b/src/Maui/Prism.Maui/PrismAppBuilder.cs
index 357f46300a..0f872aca8e 100644
--- a/src/Maui/Prism.Maui/PrismAppBuilder.cs
+++ b/src/Maui/Prism.Maui/PrismAppBuilder.cs
@@ -1,19 +1,19 @@
+using Microsoft.Maui.LifecycleEvents;
using Prism.AppModel;
using Prism.Behaviors;
using Prism.Common;
using Prism.Controls;
+using Prism.Dialogs;
using Prism.Events;
using Prism.Ioc;
using Prism.Modularity;
using Prism.Mvvm;
using Prism.Navigation;
+using Prism.Navigation.Regions;
+using Prism.Navigation.Regions.Adapters;
using Prism.Navigation.Xaml;
-using Prism.Regions.Adapters;
-using Prism.Regions.Behaviors;
using Prism.Services;
-using Microsoft.Maui.LifecycleEvents;
using TabbedPage = Microsoft.Maui.Controls.TabbedPage;
-using Prism.Dialogs;
namespace Prism;
diff --git a/src/Maui/Prism.Maui/Properties/AssemblyInfo.cs b/src/Maui/Prism.Maui/Properties/AssemblyInfo.cs
index 1436f25f18..0938be8a6b 100644
--- a/src/Maui/Prism.Maui/Properties/AssemblyInfo.cs
+++ b/src/Maui/Prism.Maui/Properties/AssemblyInfo.cs
@@ -7,6 +7,6 @@
[assembly: XmlnsDefinition("http://prismlibrary.com", "Prism.Modularity")]
[assembly: XmlnsDefinition("http://prismlibrary.com", "Prism.Mvvm")]
[assembly: XmlnsDefinition("http://prismlibrary.com", "Prism.Navigation.Xaml")]
-[assembly: XmlnsDefinition("http://prismlibrary.com", "Prism.Regions.Xaml")]
+[assembly: XmlnsDefinition("http://prismlibrary.com", "Prism.Navigation.Regions.Xaml")]
[assembly: XmlnsDefinition("http://prismlibrary.com", "Prism.Dialogs.Xaml")]
[assembly: XmlnsDefinition("http://prismlibrary.com", "Prism.Xaml")]
diff --git a/src/Maui/Prism.Maui/Regions/Behaviors/IRegionBehavior.cs b/src/Maui/Prism.Maui/Regions/Behaviors/IRegionBehavior.cs
deleted file mode 100644
index e29d1e83a4..0000000000
--- a/src/Maui/Prism.Maui/Regions/Behaviors/IRegionBehavior.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-namespace Prism.Regions.Behaviors;
-
-///
-/// Interface for allowing extensible behavior on regions.
-///
-public interface IRegionBehavior
-{
- ///
- /// The region that this behavior is extending.
- ///
- IRegion Region { get; set; }
-
- ///
- /// Attaches the behavior to the specified region.
- ///
- void Attach();
-}
diff --git a/src/Maui/Prism.Maui/Regions/Behaviors/IRegionBehaviorCollection.cs b/src/Maui/Prism.Maui/Regions/Behaviors/IRegionBehaviorCollection.cs
deleted file mode 100644
index f95df48ff2..0000000000
--- a/src/Maui/Prism.Maui/Regions/Behaviors/IRegionBehaviorCollection.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-namespace Prism.Regions.Behaviors;
-
-///
-/// Defines the interface for a collection of classes on a Region.
-///
-public interface IRegionBehaviorCollection : IEnumerable>
-{
-
- ///
- /// Adds a to the collection, using the specified key as an indexer.
- ///
- ///
- /// The key that specifies the type of that's added.
- ///
- /// The to add.
- void Add(string key, IRegionBehavior regionBehavior);
-
- ///
- /// Checks if a with the specified key is already present.
- ///
- /// The key to use to find a particular .
- ///
- bool ContainsKey(string key);
-
- ///
- /// Gets the with the specified key.
- ///
- /// The registered
- IRegionBehavior this[string key] { get; }
-}
diff --git a/src/Maui/Prism.Maui/Regions/Behaviors/IRegionBehaviorFactory.cs b/src/Maui/Prism.Maui/Regions/Behaviors/IRegionBehaviorFactory.cs
deleted file mode 100644
index 6bd82f25b2..0000000000
--- a/src/Maui/Prism.Maui/Regions/Behaviors/IRegionBehaviorFactory.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-namespace Prism.Regions.Behaviors;
-
-///
-/// Interface for RegionBehaviorFactories. This factory allows the registration of the default set of RegionBehaviors, that will
-/// be added to the s of all s, unless overridden on a 'per-region' basis.
-///
-public interface IRegionBehaviorFactory : IEnumerable
-{
- ///
- /// Adds a particular type of RegionBehavior if it was not already registered. the string is used to check if the behavior is already present
- ///
- /// Type of the behavior to add.
- /// The behavior key that's used to find if a certain behavior is already added.
- void AddIfMissing(string behaviorKey)
- where TBehavior : IRegionBehavior;
-
- ///
- /// Determines whether a behavior with the specified key already exists
- ///
- /// The behavior key.
- ///
- /// if a behavior with the specified key is present; otherwise, .
- ///
- bool ContainsKey(string behaviorKey);
-
- ///
- /// Creates an instance of the BehaviorType that's registered using the specified key.
- ///
- /// The key that's used to register a behavior type.
- /// The created behavior.
- IRegionBehavior CreateFromKey(string key);
-}
diff --git a/src/Maui/Prism.Maui/Regions/Behaviors/RegionBehavior.cs b/src/Maui/Prism.Maui/Regions/Behaviors/RegionBehavior.cs
deleted file mode 100644
index 4fa96e2b6e..0000000000
--- a/src/Maui/Prism.Maui/Regions/Behaviors/RegionBehavior.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using Prism.Properties;
-
-namespace Prism.Regions.Behaviors;
-
-///
-/// Provides a base class for region's behaviors.
-///
-public abstract class RegionBehavior : IRegionBehavior
-{
- private IRegion region;
-
- ///
- /// Behavior's attached region.
- ///
- public IRegion Region
- {
- get => region;
- set
- {
- if (IsAttached)
- {
- throw new InvalidOperationException(Resources.RegionBehaviorRegionCannotBeSetAfterAttach);
- }
-
- region = value;
- }
- }
-
- ///
- /// Returns if the behavior is attached to a region, otherwise.
- ///
- public bool IsAttached { get; private set; }
-
- ///
- /// Attaches the behavior to the region.
- ///
- public void Attach()
- {
- if (region == null)
- {
- throw new InvalidOperationException(Resources.RegionBehaviorAttachCannotBeCallWithNullRegion);
- }
-
- IsAttached = true;
- OnAttach();
- }
-
- ///
- /// Override this method to perform the logic after the behavior has been attached.
- ///
- protected abstract void OnAttach();
-}
diff --git a/src/Maui/Prism.Maui/Regions/Behaviors/RegionBehaviorCollection.cs b/src/Maui/Prism.Maui/Regions/Behaviors/RegionBehaviorCollection.cs
deleted file mode 100644
index 23facd9c15..0000000000
--- a/src/Maui/Prism.Maui/Regions/Behaviors/RegionBehaviorCollection.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-using System.Collections;
-
-namespace Prism.Regions.Behaviors;
-
-///
-/// A collection of instances, that are stored and retrieved by Key.
-///
-public class RegionBehaviorCollection : IRegionBehaviorCollection
-{
- private readonly IRegion _region;
- private readonly Dictionary _behaviors = new Dictionary();
-
- ///
- /// Initializes a new instance of the class and associates it with a region.
- ///
- /// The region to associate the behavior collection with.
- public RegionBehaviorCollection(IRegion region)
- {
- _region = region;
- }
-
- ///
- /// Gets the with the specified key.
- ///
- /// The RegionBehavior that's registered with the key.
- public IRegionBehavior this[string key] => _behaviors[key];
-
- ///
- /// Adds a to the collection, using the specified key as an indexer.
- ///
- /// The key that specifies the type of that's added.
- /// The to add.
- ///
- /// Thrown is the parameter is Null,
- /// or if the parameter is Null.
- ///
- /// Thrown if a behavior with the specified Key parameter already exists.
- public void Add(string key, IRegionBehavior regionBehavior)
- {
- if (key == null)
- throw new ArgumentNullException(nameof(key));
-
- if (regionBehavior == null)
- throw new ArgumentNullException(nameof(regionBehavior));
-
- if (_behaviors.ContainsKey(key))
- throw new ArgumentException("Could not add duplicate behavior with same key.", nameof(key));
-
- _behaviors.Add(key, regionBehavior);
- regionBehavior.Region = _region;
-
- regionBehavior.Attach();
- }
-
- ///
- /// Checks if a with the specified key is already present.
- ///
- /// The key to use to find a particular .
- ///
- public bool ContainsKey(string key) => _behaviors.ContainsKey(key);
-
- ///
- /// Returns an enumerator that iterates through the collection.
- ///
- ///
- /// A that can be used to iterate through the collection.
- ///
- public IEnumerator> GetEnumerator() => _behaviors.GetEnumerator();
-
- ///
- /// Returns an enumerator that iterates through a collection.
- ///
- ///
- /// An object that can be used to iterate through the collection.
- ///
- IEnumerator IEnumerable.GetEnumerator() => _behaviors.GetEnumerator();
-}
diff --git a/src/Maui/Prism.Maui/Regions/Behaviors/RegionBehaviorFactory.cs b/src/Maui/Prism.Maui/Regions/Behaviors/RegionBehaviorFactory.cs
deleted file mode 100644
index 2a01232f72..0000000000
--- a/src/Maui/Prism.Maui/Regions/Behaviors/RegionBehaviorFactory.cs
+++ /dev/null
@@ -1,96 +0,0 @@
-using System.Collections;
-using System.Globalization;
-using Prism.Ioc;
-using Prism.Properties;
-
-namespace Prism.Regions.Behaviors;
-
-///
-/// Defines a factory that allows the registration of the default set of , that will
-/// be added to the of all s, unless overridden on a 'per-region' basis.
-///
-public class RegionBehaviorFactory : IRegionBehaviorFactory
-{
- private readonly IContainerProvider _container;
- private readonly Dictionary _registeredBehaviors = new Dictionary();
-
- ///
- /// Initializes a new instance of .
- ///
- /// used to create the instance of the behavior from its .
- public RegionBehaviorFactory(IContainerExtension container)
- {
- _container = container;
- }
-
- ///
- /// Adds a particular type of RegionBehavior if it was not already registered. The string is used to check if the behavior is already present
- ///
- /// Type of the behavior to add.
- /// The behavior key that's used to find if a certain behavior is already added.
- public void AddIfMissing(string behaviorKey)
- where TBehavior : IRegionBehavior
- {
- if (behaviorKey == null)
- {
- throw new ArgumentNullException(nameof(behaviorKey));
- }
-
- var behaviorType = typeof(TBehavior);
-
- // Only add the behaviorKey if it doesn't already exists.
- if (_registeredBehaviors.ContainsKey(behaviorKey))
- {
- return;
- }
-
- _registeredBehaviors.Add(behaviorKey, behaviorType);
- }
-
- ///
- /// Creates an instance of the behavior that is registered using the specified key.
- ///
- /// The key that is used to register a behavior type.
- /// A new instance of the behavior.
- public IRegionBehavior CreateFromKey(string key)
- {
- if (!ContainsKey(key))
- {
- throw new ArgumentException(
- string.Format(CultureInfo.CurrentUICulture, Resources.TypeWithKeyNotRegistered, key), nameof(key));
- }
-
- return (IRegionBehavior)_container.Resolve(_registeredBehaviors[key]);
- }
-
-
- ///
- /// Returns an enumerator that iterates through the collection.
- ///
- ///
- /// A that can be used to iterate through the collection.
- ///
- /// 1
- public IEnumerator GetEnumerator() =>
- _registeredBehaviors.Keys.GetEnumerator();
-
- ///
- /// Returns an enumerator that iterates through a collection.
- ///
- ///
- /// An object that can be used to iterate through the collection.
- ///
- /// 2
- IEnumerator IEnumerable.GetEnumerator() =>
- GetEnumerator();
-
- ///
- /// Determines whether a behavior with the specified key already exists.
- ///
- /// The behavior key.
- ///
- /// if a behavior with the specified key is present; otherwise, .
- ///
- public bool ContainsKey(string behaviorKey) =>
- _registeredBehaviors.ContainsKey(behaviorKey);
-}
diff --git a/src/Maui/Prism.Maui/Regions/IRegion.cs b/src/Maui/Prism.Maui/Regions/IRegion.cs
deleted file mode 100644
index 35412a9ca1..0000000000
--- a/src/Maui/Prism.Maui/Regions/IRegion.cs
+++ /dev/null
@@ -1,117 +0,0 @@
-using System.ComponentModel;
-using Prism.Regions.Behaviors;
-using Prism.Regions.Navigation;
-
-namespace Prism.Regions;
-
-///
-/// Defines a model that can be used to compose views.
-///
-public interface IRegion : INotifyPropertyChanged
-{
- ///
- /// Gets a readonly view of the collection of views in the region.
- ///
- /// An of all the added views.
- IViewsCollection Views { get; }
-
- ///
- /// Gets a readonly view of the collection of all the active views in the region.
- ///
- /// An of all the active views.
- IViewsCollection ActiveViews { get; }
-
- ///
- /// Gets or sets a context for the region. This value can be used by the user to share context with the views.
- ///
- /// The context value to be shared.
- object Context { get; set; }
-
- ///
- /// Gets the name of the region that uniquely identifies the region within a .
- ///
- /// The name of the region.
- string Name { get; set; }
-
- ///
- /// Gets or sets the comparison used to sort the views.
- ///
- /// The comparison to use.
- Comparison SortComparison { get; set; }
-
- IRegionManager Add(string viewName);
-
- ///Adds a new view to the region.
- ///
- /// Adds a new view to the region.
- ///
- /// The view to add.
- /// The that is set on the view if it is a . It will be the current region manager when using this overload.
- IRegionManager Add(VisualElement view);
-
- ///
- /// Adds a new view to the region.
- ///
- /// The view to add.
- /// The name of the view. This can be used to retrieve it later by calling .
- /// The that is set on the view if it is a . It will be the current region manager when using this overload.
- IRegionManager Add(VisualElement view, string viewName);
-
- ///
- /// Adds a new view to the region.
- ///
- /// The view to add.
- /// The name of the view. This can be used to retrieve it later by calling .
- /// When , the added view will receive a new instance of , otherwise it will use the current region manager for this region.
- /// The that is set on the view if it is a .
- IRegionManager Add(VisualElement view, string viewName, bool createRegionManagerScope);
-
- ///
- /// Removes the specified view from the region.
- ///
- /// The view to remove.
- void Remove(VisualElement view);
-
- ///
- /// Removes all views from the region.
- ///
- void RemoveAll();
-
- ///
- /// Marks the specified view as active.
- ///
- /// The view to activate.
- void Activate(VisualElement view);
-
- ///
- /// Marks the specified view as inactive.
- ///
- /// The view to deactivate.
- void Deactivate(VisualElement view);
-
- ///
- /// Returns the view instance that was added to the region using a specific name.
- ///
- /// The name used when adding the view to the region.
- /// Returns the named view or if the view with does not exist in the current region.
- VisualElement GetView(string viewName);
-
- ///
- /// Gets or sets the that will be passed to the views when adding them to the region, unless the view is added by specifying createRegionManagerScope as .
- ///
- /// The where this is registered.
- /// This is usually used by implementations of and should not be
- /// used by the developer explicitly.
- IRegionManager RegionManager { get; set; }
-
- ///
- /// Gets the collection of s that can extend the behavior of regions.
- ///
- IRegionBehaviorCollection Behaviors { get; }
-
- ///
- /// Gets or sets the navigation service.
- ///
- /// The navigation service.
- IRegionNavigationService NavigationService { get; }
-}
diff --git a/src/Maui/Prism.Maui/Regions/IRegionCollection.cs b/src/Maui/Prism.Maui/Regions/IRegionCollection.cs
deleted file mode 100644
index c7cc0a7d61..0000000000
--- a/src/Maui/Prism.Maui/Regions/IRegionCollection.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-using System.Collections.Specialized;
-
-namespace Prism.Regions;
-
-///
-/// Defines a collection of uniquely identified by their Name.
-///
-public interface IRegionCollection : IEnumerable, INotifyCollectionChanged
-{
- ///
- /// Gets the IRegion with the name received as index.
- ///
- /// Name of the region to be retrieved.
- /// The identified with the requested name.
- IRegion this[string regionName] { get; }
-
- ///
- /// Adds a to the collection.
- ///
- /// Region to be added to the collection.
- void Add(IRegion region);
-
- ///
- /// Removes a from the collection.
- ///
- /// Name of the region to be removed.
- /// if the region was removed from the collection, otherwise .
- bool Remove(string regionName);
-
- ///
- /// Checks if the collection contains a with the name received as parameter.
- ///
- /// The name of the region to look for.
- /// if the region is contained in the collection, otherwise .
- bool ContainsRegionWithName(string regionName);
-
- ///
- /// Adds a region to the with the name received as argument.
- ///
- /// The name to be given to the region.
- /// The region to be added to the .
- /// Thrown if is .
- /// Thrown if and 's name do not match and the is not .
- void Add(string regionName, IRegion region);
-}
diff --git a/src/Maui/Prism.Maui/Regions/IRegionManager.cs b/src/Maui/Prism.Maui/Regions/IRegionManager.cs
deleted file mode 100644
index 4e453a46a7..0000000000
--- a/src/Maui/Prism.Maui/Regions/IRegionManager.cs
+++ /dev/null
@@ -1,74 +0,0 @@
-using Prism.Navigation;
-using Prism.Regions.Navigation;
-
-namespace Prism.Regions;
-
-///
-/// Defines an interface to manage a set of regions and to attach regions to objects (typically controls).
-///
-public interface IRegionManager
-{
- ///
- /// Gets a collection of that identify each region by name. You can use this collection to add or remove regions to the current region manager.
- ///
- IRegionCollection Regions { get; }
-
- ///
- /// Creates a new region manager.
- ///
- /// A new region manager that can be used as a different scope from the current region manager.
- IRegionManager CreateRegionManager();
-
- ///
- /// Add a view to the Views collection of a Region. Note that the region must already exist in this .
- ///
- /// The name of the region to add a view to
- /// The view to add to the views collection
- /// The RegionManager, to easily add several views.
- IRegionManager AddToRegion(string regionName, string targetName);
-
- ///
- /// Associate a view with a region, by registering a type. When the region get's displayed
- /// this type will be resolved using the ServiceLocator into a concrete instance. The instance
- /// will be added to the Views collection of the region
- ///
- /// The name of the region to associate the view with.
- /// The type of the view to register with the
- /// The , for adding several views easily
- IRegionManager RegisterViewWithRegion(string regionName, string targetName);
-
- ///
- /// Associate a view with a region, by registering a type. When the region get's displayed
- /// this type will be resolved using the ServiceLocator into a concrete instance. The instance
- /// will be added to the Views collection of the region
- ///
- /// The name of the region to associate the view with.
- /// The type of the view to register with the .
- /// The , for adding several views easily
- IRegionManager RegisterViewWithRegion(string regionName, Type viewType);
-
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The name of the Region to navigate to.
- /// The navigation target
- /// The callback executed when the navigation request is completed.
- ///
- /// Convenience overloads for this method can be found as extension methods on the
- /// class.
- ///
- void RequestNavigate(string regionName, Uri target, Action navigationCallback);
-
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The name of the Region to navigate to.
- /// The navigation target
- /// The callback executed when the navigation request is completed.
- /// The navigation parameters specific to the navigation request.
- ///
- /// Convenience overloads for this method can be found as extension methods on the
- /// class.
- ///
- void RequestNavigate(string regionName, Uri target, Action navigationCallback, INavigationParameters navigationParameters);
-}
diff --git a/src/Maui/Prism.Maui/Regions/IRegionManagerExtensions.cs b/src/Maui/Prism.Maui/Regions/IRegionManagerExtensions.cs
deleted file mode 100644
index 4c7e9c06e3..0000000000
--- a/src/Maui/Prism.Maui/Regions/IRegionManagerExtensions.cs
+++ /dev/null
@@ -1,121 +0,0 @@
-using Prism.Navigation;
-using Prism.Regions.Navigation;
-
-namespace Prism.Regions;
-
-///
-/// NavigationExtensions for the
-///
-public static class IRegionManagerExtensions
-{
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The navigation object.
- /// The name of the Region to navigate to.
- /// The navigation target
- public static void RequestNavigate(this IRegionManager regionManager, string regionName, string target)
- {
- RequestNavigate(regionManager, regionName, target, nr => { });
- }
-
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The navigation object.
- /// The name of the Region to navigate to.
- /// The navigation target
- /// The callback executed when the navigation request is completed.
- public static void RequestNavigate(this IRegionManager regionManager, string regionName, string target, Action navigationCallback)
- {
- if (regionManager == null)
- throw new ArgumentNullException(nameof(regionManager));
-
- if (target == null)
- throw new ArgumentNullException(nameof(target));
-
- var targetUri = new Uri(target, UriKind.RelativeOrAbsolute);
-
- regionManager.RequestNavigate(regionName, targetUri, navigationCallback);
- }
-
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The navigation object.
- /// The name of the Region to navigate to.
- /// The navigation target
- public static void RequestNavigate(this IRegionManager regionManager, string regionName, Uri target)
- {
- if (regionManager == null)
- throw new ArgumentNullException(nameof(regionManager));
-
- regionManager.RequestNavigate(regionName, target, nr => { });
- }
-
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The navigation object.
- /// The name of the Region to navigate to.
- /// The navigation target
- /// The callback executed when the navigation request is completed.
- /// An instance of NavigationParameters, which holds a collection of object parameters.
- public static void RequestNavigate(this IRegionManager regionManager, string regionName, string target, Action navigationCallback, INavigationParameters regionParameters)
- {
- if (regionManager == null)
- throw new ArgumentNullException(nameof(regionManager));
-
- if (target == null)
- throw new ArgumentNullException(nameof(target));
-
- var targetUri = new Uri(target, UriKind.RelativeOrAbsolute);
-
- regionManager.RequestNavigate(regionName, targetUri, navigationCallback, regionParameters);
- }
-
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The RegionManager object.
- /// The name of the Region to navigate to.
- /// A Uri that represents the target where the region will navigate.
- /// An instance of NavigationParameters, which holds a collection of object parameters.
- public static void RequestNavigate(this IRegionManager regionManager, string regionName, Uri target, INavigationParameters regionParameters)
- {
- if (regionManager == null)
- throw new ArgumentNullException(nameof(regionManager));
-
- regionManager.RequestNavigate(regionName, target, nr => { }, regionParameters);
- }
-
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The RegionManager object.
- /// The name of the Region to navigate to.
- /// A string that represents the target where the region will navigate.
- /// An instance of NavigationParameters, which holds a collection of object parameters.
- public static void RequestNavigate(this IRegionManager regionManager, string regionName, string target, INavigationParameters regionParameters)
- {
- if (regionManager == null)
- throw new ArgumentNullException(nameof(regionManager));
-
- if (target == null)
- throw new ArgumentNullException(nameof(target));
-
- regionManager.RequestNavigate(regionName, new Uri(target, UriKind.RelativeOrAbsolute), nr => { }, regionParameters);
- }
-
- ///
- /// Associate a view with a region, by registering a type. When the region get's displayed
- /// this type will be resolved using the ServiceLocator into a concrete instance. The instance
- /// will be added to the Views collection of the region
- ///
- /// The type of the view to register with the .
- /// The current .
- /// The name of the region to associate the view with.
- /// The , for adding several views easily
- public static IRegionManager RegisterViewWithRegion(this IRegionManager regionManager, string regionName) =>
- regionManager.RegisterViewWithRegion(regionName, typeof(T));
-}
diff --git a/src/Maui/Prism.Maui/Regions/IRegionViewRegistry.cs b/src/Maui/Prism.Maui/Regions/IRegionViewRegistry.cs
deleted file mode 100644
index 1b28cc96cb..0000000000
--- a/src/Maui/Prism.Maui/Regions/IRegionViewRegistry.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-using Prism.Ioc;
-
-namespace Prism.Regions;
-
-///
-/// Defines the interface for the registry of region's content.
-///
-public interface IRegionViewRegistry
-{
- ///
- /// Event triggered when a content is registered to a region name.
- ///
- ///
- /// This event uses weak references to the event handler to prevent this service (typically a singleton) of keeping the
- /// target element longer than expected.
- ///
- event EventHandler ContentRegistered;
-
- ///
- /// Returns the contents associated with a region name.
- ///
- /// Region name for which contents are requested.
- /// Collection of contents associated with the .
- IEnumerable GetContents(string regionName, IContainerProvider container);
-
- ///
- /// Registers a content type with a region name.
- ///
- /// Region name to which the will be registered.
- /// Content type to be registered for the .
- void RegisterViewWithRegion(string regionName, Type viewType);
-
- ///
- /// Registers a content type with a region name.
- ///
- /// Region name to which the will be registered.
- /// Content type to be registered for the .
- void RegisterViewWithRegion(string regionName, string targetName);
-
- ///
- /// Registers a delegate that can be used to retrieve the content associated with a region name.
- ///
- /// Region name to which the will be registered.
- /// Delegate used to retrieve the content associated with the .
- void RegisterViewWithRegion(string regionName, Func getContentDelegate);
-}
diff --git a/src/Maui/Prism.Maui/Regions/IViewsCollection.cs b/src/Maui/Prism.Maui/Regions/IViewsCollection.cs
deleted file mode 100644
index 079de4d1b7..0000000000
--- a/src/Maui/Prism.Maui/Regions/IViewsCollection.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-using System.Collections.Specialized;
-
-namespace Prism.Regions;
-
-public interface IViewsCollection : IEnumerable, INotifyCollectionChanged
-{
- bool Contains(VisualElement element);
-}
diff --git a/src/Maui/Prism.Maui/Regions/Navigation/IConfirmRegionNavigationRequest.cs b/src/Maui/Prism.Maui/Regions/Navigation/IConfirmRegionNavigationRequest.cs
deleted file mode 100644
index fe3e0730d7..0000000000
--- a/src/Maui/Prism.Maui/Regions/Navigation/IConfirmRegionNavigationRequest.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-namespace Prism.Regions.Navigation;
-
-///
-/// Provides a way for objects involved in navigation to determine if a navigation request should continue.
-///
-public interface IConfirmRegionNavigationRequest : IRegionAware
-{
- ///
- /// Determines whether this instance accepts being navigated away from.
- ///
- /// The navigation context.
- /// The callback to indicate when navigation can proceed.
- ///
- /// Implementors of this method do not need to invoke the callback before this method is completed,
- /// but they must ensure the callback is eventually invoked.
- ///
- void ConfirmNavigationRequest(INavigationContext navigationContext, Action continuationCallback);
-}
diff --git a/src/Maui/Prism.Maui/Regions/Navigation/IJournalAware.cs b/src/Maui/Prism.Maui/Regions/Navigation/IJournalAware.cs
deleted file mode 100644
index 5a3f2fa263..0000000000
--- a/src/Maui/Prism.Maui/Regions/Navigation/IJournalAware.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-namespace Prism.Regions.Navigation;
-
-///
-/// Provides a way for objects involved in navigation to opt-out of being added to the IRegionNavigationJournal backstack.
-///
-public interface IJournalAware
-{
- ///
- /// Determines if the current object is going to be added to the navigation journal's backstack.
- ///
- /// True, add to backstack. False, remove from backstack.
- bool PersistInHistory();
-}
diff --git a/src/Maui/Prism.Maui/Regions/Navigation/INavigateAsync.cs b/src/Maui/Prism.Maui/Regions/Navigation/INavigateAsync.cs
deleted file mode 100644
index 8916aa60da..0000000000
--- a/src/Maui/Prism.Maui/Regions/Navigation/INavigateAsync.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using Prism.Navigation;
-
-namespace Prism.Regions.Navigation;
-
-///
-/// Provides methods to perform navigation.
-///
-///
-/// Convenience overloads for the methods in this interface can be found as extension methods on the
-/// class.
-///
-public interface INavigateAsync
-{
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The navigation target
- /// The callback executed when the navigation request is completed.
- ///
- /// Convenience overloads for this method can be found as extension methods on the
- /// class.
- ///
- void RequestNavigate(Uri target, Action navigationCallback);
-
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The navigation target
- /// The callback executed when the navigation request is completed.
- /// The navigation parameters specific to the navigation request.
- ///
- /// Convenience overloads for this method can be found as extension methods on the
- /// class.
- ///
- void RequestNavigate(Uri target, Action navigationCallback, INavigationParameters navigationParameters);
-}
diff --git a/src/Maui/Prism.Maui/Regions/Navigation/INavigationContext.cs b/src/Maui/Prism.Maui/Regions/Navigation/INavigationContext.cs
deleted file mode 100644
index 4f7c2c1b7b..0000000000
--- a/src/Maui/Prism.Maui/Regions/Navigation/INavigationContext.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using Prism.Navigation;
-
-namespace Prism.Regions.Navigation;
-
-///
-/// Encapsulates information about a navigation request.
-///
-public interface INavigationContext
-{
- ///
- /// Gets the region navigation service.
- ///
- /// The navigation service.
- IRegionNavigationService NavigationService { get; }
-
- ///
- /// Gets the extracted from the URI and the object parameters passed in navigation.
- ///
- /// The URI query.
- INavigationParameters Parameters { get; }
-
- ///
- /// Gets the navigation URI.
- ///
- /// The navigation URI.
- Uri Uri { get; }
-}
diff --git a/src/Maui/Prism.Maui/Regions/Navigation/INavigationContextExtensions.cs b/src/Maui/Prism.Maui/Regions/Navigation/INavigationContextExtensions.cs
deleted file mode 100644
index 922958ba45..0000000000
--- a/src/Maui/Prism.Maui/Regions/Navigation/INavigationContextExtensions.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-namespace Prism.Regions.Navigation;
-
-public static class INavigationContextExtensions
-{
- public static string NavigatedName(this INavigationContext context)
- {
- var uri = context.Uri;
- if (!uri.IsAbsoluteUri)
- {
- uri = new Uri(new Uri("nav://local.app"), context.Uri);
- }
-
- return uri.LocalPath.StartsWith("/") ? uri.LocalPath.Substring(1) : uri.LocalPath;
- }
-}
diff --git a/src/Maui/Prism.Maui/Regions/Navigation/IRegionAware.cs b/src/Maui/Prism.Maui/Regions/Navigation/IRegionAware.cs
deleted file mode 100644
index dca06b7776..0000000000
--- a/src/Maui/Prism.Maui/Regions/Navigation/IRegionAware.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-namespace Prism.Regions.Navigation;
-
-///
-/// Provides a way for objects involved in navigation to be notified of navigation activities.
-///
-public interface IRegionAware
-{
- ///
- /// Called when the implementer has been navigated to.
- ///
- /// The navigation context.
- void OnNavigatedTo(INavigationContext navigationContext);
-
- ///
- /// Called to determine if this instance can handle the navigation request.
- ///
- /// The navigation context.
- ///
- /// if this instance accepts the navigation request; otherwise, .
- ///
- bool IsNavigationTarget(INavigationContext navigationContext);
-
- ///
- /// Called when the implementer is being navigated away from.
- ///
- /// The navigation context.
- void OnNavigatedFrom(INavigationContext navigationContext);
-}
diff --git a/src/Maui/Prism.Maui/Regions/Navigation/IRegionNavigationContentLoader.cs b/src/Maui/Prism.Maui/Regions/Navigation/IRegionNavigationContentLoader.cs
deleted file mode 100644
index 6c015d26ca..0000000000
--- a/src/Maui/Prism.Maui/Regions/Navigation/IRegionNavigationContentLoader.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-namespace Prism.Regions.Navigation;
-
-///
-/// Identifies the view in a region that is the target of a navigation request.
-///
-public interface IRegionNavigationContentLoader
-{
- ///
- /// Gets the content to which the navigation request represented by applies.
- ///
- ///
- /// If none of the items in the region match the target of the navigation request, a new item
- /// will be created and added to the region.
- ///
- /// The region.
- /// The context representing the navigation request.
- /// The item to be the target of the navigation request.
- /// when a new item cannot be created for the navigation request.
- object LoadContent(IRegion region, INavigationContext navigationContext);
-}
diff --git a/src/Maui/Prism.Maui/Regions/Navigation/IRegionNavigationJournal.cs b/src/Maui/Prism.Maui/Regions/Navigation/IRegionNavigationJournal.cs
deleted file mode 100644
index 3f58c4da25..0000000000
--- a/src/Maui/Prism.Maui/Regions/Navigation/IRegionNavigationJournal.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-namespace Prism.Regions.Navigation;
-
-///
-/// Provides journaling of current, back, and forward navigation within regions.
-///
-public interface IRegionNavigationJournal
-{
- ///
- /// Gets a value that indicates whether there is at least one entry in the back navigation history.
- ///
- ///
- /// true if the journal can go back; otherwise, false.
- ///
- bool CanGoBack { get; }
-
- ///
- /// Gets a value that indicates whether there is at least one entry in the forward navigation history.
- ///
- ///
- /// true if this instance can go forward; otherwise, false.
- ///
- bool CanGoForward { get; }
-
- ///
- /// Gets the current navigation entry of the content that is currently displayed.
- ///
- /// The current entry.
- IRegionNavigationJournalEntry CurrentEntry { get; }
-
- ///
- /// Gets or sets the target that implements INavigateAsync.
- ///
- /// The INavigate implementation.
- ///
- /// This is set by the owner of this journal.
- ///
- INavigateAsync NavigationTarget { get; set; }
-
- ///
- /// Navigates to the most recent entry in the back navigation history, or does nothing if no entry exists in back navigation.
- ///
- void GoBack();
-
- ///
- /// Navigates to the most recent entry in the forward navigation history, or does nothing if no entry exists in forward navigation.
- ///
- void GoForward();
-
- ///
- /// Records the navigation to the entry..
- ///
- /// The entry to record.
- /// true if you it should be persisted in history
- void RecordNavigation(IRegionNavigationJournalEntry entry, bool persistInHistory);
-
- ///
- /// Clears the journal of current, back, and forward navigation histories.
- ///
- void Clear();
-}
diff --git a/src/Maui/Prism.Maui/Regions/Navigation/IRegionNavigationJournalEntry.cs b/src/Maui/Prism.Maui/Regions/Navigation/IRegionNavigationJournalEntry.cs
deleted file mode 100644
index 607f2ec4c7..0000000000
--- a/src/Maui/Prism.Maui/Regions/Navigation/IRegionNavigationJournalEntry.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using Prism.Navigation;
-
-namespace Prism.Regions.Navigation;
-
-///
-/// An entry in an IRegionNavigationJournal representing the URI navigated to.
-///
-public interface IRegionNavigationJournalEntry
-{
- ///
- /// Gets or sets the URI.
- ///
- /// The URI.
- Uri Uri { get; set; }
-
- ///
- /// Gets or sets the NavigationParameters instance.
- ///
- INavigationParameters Parameters { get; set; }
-}
diff --git a/src/Maui/Prism.Maui/Regions/Navigation/IRegionNavigationResult.cs b/src/Maui/Prism.Maui/Regions/Navigation/IRegionNavigationResult.cs
deleted file mode 100644
index 9932311a7d..0000000000
--- a/src/Maui/Prism.Maui/Regions/Navigation/IRegionNavigationResult.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-namespace Prism.Regions.Navigation;
-
-///
-/// Represents the result of navigating to a URI.
-///
-public interface IRegionNavigationResult
-{
- ///
- /// Gets the navigation context.
- ///
- /// The navigation context.
- INavigationContext Context { get; }
-
- ///
- /// Gets an exception that occurred while navigating.
- ///
- /// The exception.
- Exception Error { get; }
-
- ///
- /// Gets the result.
- ///
- /// The result.
- bool? Result { get; }
-}
diff --git a/src/Maui/Prism.Maui/Regions/Navigation/IRegionNavigationService.cs b/src/Maui/Prism.Maui/Regions/Navigation/IRegionNavigationService.cs
deleted file mode 100644
index 2c12f5ebe8..0000000000
--- a/src/Maui/Prism.Maui/Regions/Navigation/IRegionNavigationService.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-namespace Prism.Regions.Navigation;
-
-///
-/// Provides navigation for regions.
-///
-public interface IRegionNavigationService : INavigateAsync
-{
- ///
- /// Gets or sets the region owning this service.
- ///
- /// A Region.
- IRegion Region { get; set; }
-
- ///
- /// Gets the journal.
- ///
- /// The journal.
- IRegionNavigationJournal Journal { get; }
-
- ///
- /// Raised when the region is about to be navigated to content.
- ///
- event EventHandler Navigating;
-
- ///
- /// Raised when the region is navigated to content.
- ///
- event EventHandler Navigated;
-
- ///
- /// Raised when a navigation request fails.
- ///
- event EventHandler NavigationFailed;
-}
diff --git a/src/Maui/Prism.Maui/Regions/Navigation/NavigationAsyncExtensions.cs b/src/Maui/Prism.Maui/Regions/Navigation/NavigationAsyncExtensions.cs
deleted file mode 100644
index 6b751fca31..0000000000
--- a/src/Maui/Prism.Maui/Regions/Navigation/NavigationAsyncExtensions.cs
+++ /dev/null
@@ -1,102 +0,0 @@
-using Prism.Navigation;
-
-namespace Prism.Regions.Navigation;
-
-///
-/// Provides additional methods to the interface.
-///
-public static class NavigationAsyncExtensions
-{
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The navigation object.
- /// The navigation target
- public static void RequestNavigate(this INavigateAsync navigation, string target)
- {
- RequestNavigate(navigation, target, nr => { });
- }
-
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The navigation object.
- /// The navigation target
- /// The callback executed when the navigation request is completed.
- public static void RequestNavigate(this INavigateAsync navigation, string target, Action navigationCallback)
- {
- if (navigation == null)
- throw new ArgumentNullException(nameof(navigation));
-
- if (target == null)
- throw new ArgumentNullException(nameof(target));
-
- var targetUri = new Uri(target, UriKind.RelativeOrAbsolute);
-
- navigation.RequestNavigate(targetUri, navigationCallback);
- }
-
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The navigation object.
- /// The navigation target
- public static void RequestNavigate(this INavigateAsync navigation, Uri target)
- {
- if (navigation == null)
- throw new ArgumentNullException(nameof(navigation));
-
- navigation.RequestNavigate(target, nr => { });
- }
-
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The navigation object.
- /// The navigation target
- /// The callback executed when the navigation request is completed.
- /// An instance of NavigationParameters, which holds a collection of object parameters.
- public static void RequestNavigate(this INavigateAsync navigation, string target, Action navigationCallback, INavigationParameters regionParameters)
- {
- if (navigation == null)
- throw new ArgumentNullException(nameof(navigation));
-
- if (target == null)
- throw new ArgumentNullException(nameof(target));
-
- var targetUri = new Uri(target, UriKind.RelativeOrAbsolute);
-
- navigation.RequestNavigate(targetUri, navigationCallback, regionParameters);
- }
-
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The navigation object.
- /// A Uri that represents the target where the region will navigate.
- /// An instance of NavigationParameters, which holds a collection of object parameters.
- public static void RequestNavigate(this INavigateAsync navigation, Uri target, INavigationParameters regionParameters)
- {
- if (navigation == null)
- throw new ArgumentNullException(nameof(navigation));
-
- navigation.RequestNavigate(target, nr => { }, regionParameters);
- }
-
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The navigation object.
- /// A string that represents the target where the region will navigate.
- /// An instance of NavigationParameters, which holds a collection of object parameters.
- public static void RequestNavigate(this INavigateAsync navigation, string target, INavigationParameters regionParameters)
- {
- if (navigation == null)
- throw new ArgumentNullException(nameof(navigation));
-
- if (target == null)
- throw new ArgumentNullException(nameof(target));
-
- navigation.RequestNavigate(new Uri(target, UriKind.RelativeOrAbsolute), nr => { }, regionParameters);
- }
-}
diff --git a/src/Maui/Prism.Maui/Regions/Navigation/NavigationContext.cs b/src/Maui/Prism.Maui/Regions/Navigation/NavigationContext.cs
deleted file mode 100644
index e6bd59450a..0000000000
--- a/src/Maui/Prism.Maui/Regions/Navigation/NavigationContext.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-using Prism.Common;
-using Prism.Navigation;
-
-namespace Prism.Regions.Navigation;
-
-///
-/// Encapsulates information about a navigation request.
-///
-public class NavigationContext : INavigationContext
-{
- ///
- /// Initializes a new instance of the class for a region name and a
- /// .
- ///
- /// The navigation service.
- /// The Uri.
- public NavigationContext(IRegionNavigationService navigationService, Uri uri)
- : this(navigationService, uri, null)
- {
- }
-
- ///
- /// Initializes a new instance of the class for a region name and a
- /// .
- ///
- /// The navigation service.
- /// The navigation parameters.
- /// The Uri.
- public NavigationContext(IRegionNavigationService navigationService, Uri uri, INavigationParameters regionParameters)
- {
- NavigationService = navigationService;
- Uri = uri;
- Parameters = regionParameters ?? new NavigationParameters();
-
- var queryString = uri != null ? UriParsingHelper.EnsureAbsolute(uri).Query : null;
- if (!string.IsNullOrEmpty(queryString))
- {
- UpdateRegionParameters(new NavigationParameters(queryString));
- }
- }
-
- ///
- /// Gets the region navigation service.
- ///
- /// The navigation service.
- public IRegionNavigationService NavigationService { get; private set; }
-
- ///
- /// Gets the navigation URI.
- ///
- /// The navigation URI.
- public Uri Uri { get; }
-
- ///
- /// Gets the extracted from the URI and the object parameters passed in navigation.
- ///
- /// The URI query.
- public INavigationParameters Parameters { get; }
-
- private void UpdateRegionParameters(INavigationParameters regionParameters)
- {
- foreach (KeyValuePair parameter in regionParameters)
- {
- Parameters.Add(parameter.Key, parameter.Value);
- }
- }
-}
diff --git a/src/Maui/Prism.Maui/Regions/Navigation/RegionNavigationEventArgs.cs b/src/Maui/Prism.Maui/Regions/Navigation/RegionNavigationEventArgs.cs
deleted file mode 100644
index 0b8eb7cd77..0000000000
--- a/src/Maui/Prism.Maui/Regions/Navigation/RegionNavigationEventArgs.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-namespace Prism.Regions.Navigation;
-
-///
-/// EventArgs used with the Navigated event.
-///
-public class RegionNavigationEventArgs : EventArgs
-{
- ///
- /// Initializes a new instance of the class.
- ///
- /// The navigation context.
- public RegionNavigationEventArgs(INavigationContext navigationContext)
- {
- NavigationContext = navigationContext ?? throw new ArgumentNullException(nameof(navigationContext));
- }
-
- ///
- /// Gets the navigation context.
- ///
- /// The navigation context.
- public INavigationContext NavigationContext { get; }
-
- ///
- /// Gets the navigation URI
- ///
- /// The URI.
- ///
- /// This is a convenience accessor around NavigationContext.Uri.
- ///
- public Uri Uri => NavigationContext?.Uri;
-}
diff --git a/src/Maui/Prism.Maui/Regions/Navigation/RegionNavigationFailedEventArgs.cs b/src/Maui/Prism.Maui/Regions/Navigation/RegionNavigationFailedEventArgs.cs
deleted file mode 100644
index 00a827971f..0000000000
--- a/src/Maui/Prism.Maui/Regions/Navigation/RegionNavigationFailedEventArgs.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-namespace Prism.Regions.Navigation;
-
-///
-/// EventArgs used with the NavigationFailed event.
-///
-public class RegionNavigationFailedEventArgs : EventArgs
-{
- ///
- /// Initializes a new instance of the class.
- ///
- /// The navigation context.
- public RegionNavigationFailedEventArgs(INavigationContext navigationContext)
- {
- NavigationContext = navigationContext ?? throw new ArgumentNullException(nameof(navigationContext));
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The navigation context.
- /// The error.
- public RegionNavigationFailedEventArgs(INavigationContext navigationContext, Exception error)
- : this(navigationContext)
- {
- Error = error;
- }
-
- ///
- /// Gets the navigation context.
- ///
- /// The navigation context.
- public INavigationContext NavigationContext { get; }
-
- ///
- /// Gets the error.
- ///
- /// The , or if the failure was not caused by an exception.
- public Exception Error { get; }
-
- ///
- /// Gets the navigation URI
- ///
- /// The URI.
- ///
- /// This is a convenience accessor around NavigationContext.Uri.
- ///
- public Uri Uri => NavigationContext?.Uri;
-}
diff --git a/src/Maui/Prism.Maui/Regions/Navigation/RegionNavigationJournal.cs b/src/Maui/Prism.Maui/Regions/Navigation/RegionNavigationJournal.cs
deleted file mode 100644
index d30bd7a89f..0000000000
--- a/src/Maui/Prism.Maui/Regions/Navigation/RegionNavigationJournal.cs
+++ /dev/null
@@ -1,143 +0,0 @@
-namespace Prism.Regions.Navigation;
-
-///
-/// Provides journaling of current, back, and forward navigation within regions.
-///
-public class RegionNavigationJournal : IRegionNavigationJournal
-{
- private readonly Stack _backStack = new Stack();
- private readonly Stack _forwardStack = new Stack();
-
- private bool _isNavigatingInternal;
-
- ///
- /// Gets or sets the target that implements INavigate.
- ///
- /// The INavigate implementation.
- ///
- /// This is set by the owner of this journal.
- ///
- public INavigateAsync NavigationTarget { get; set; }
-
- ///
- /// Gets the current navigation entry of the content that is currently displayed.
- ///
- /// The current entry.
- public IRegionNavigationJournalEntry CurrentEntry { get; private set; }
-
- ///
- /// Gets a value that indicates whether there is at least one entry in the back navigation history.
- ///
- /// true if the journal can go back; otherwise, false.
- public bool CanGoBack => _backStack.Count > 0;
-
- ///
- /// Gets a value that indicates whether there is at least one entry in the forward navigation history.
- ///
- ///
- /// true if this instance can go forward; otherwise, false.
- ///
- public bool CanGoForward => _forwardStack.Count > 0;
-
- ///
- /// Navigates to the most recent entry in the back navigation history, or does nothing if no entry exists in back navigation.
- ///
- public void GoBack()
- {
- if (CanGoBack)
- {
- IRegionNavigationJournalEntry entry = _backStack.Peek();
- InternalNavigate(
- entry,
- result =>
- {
- if (result)
- {
- if (CurrentEntry != null)
- {
- _forwardStack.Push(CurrentEntry);
- }
-
- _backStack.Pop();
- CurrentEntry = entry;
- }
- });
- }
- }
-
- ///
- /// Navigates to the most recent entry in the forward navigation history, or does nothing if no entry exists in forward navigation.
- ///
- public void GoForward()
- {
- if (CanGoForward)
- {
- IRegionNavigationJournalEntry entry = _forwardStack.Peek();
- InternalNavigate(
- entry,
- result =>
- {
- if (result)
- {
- if (CurrentEntry != null)
- {
- _backStack.Push(CurrentEntry);
- }
-
- _forwardStack.Pop();
- CurrentEntry = entry;
- }
- });
- }
- }
-
- ///
- /// Records the navigation to the entry..
- ///
- /// The entry to record.
- /// Determine if the view is added to the back stack or excluded from the history.
- public void RecordNavigation(IRegionNavigationJournalEntry entry, bool persistInHistory)
- {
- if (!_isNavigatingInternal)
- {
- if (CurrentEntry != null)
- {
- _backStack.Push(CurrentEntry);
- }
-
- _forwardStack.Clear();
-
- if (persistInHistory)
- CurrentEntry = entry;
- else
- CurrentEntry = null;
- }
- }
-
- ///
- /// Clears the journal of current, back, and forward navigation histories.
- ///
- public void Clear()
- {
- CurrentEntry = null;
- _backStack.Clear();
- _forwardStack.Clear();
- }
-
- private void InternalNavigate(IRegionNavigationJournalEntry entry, Action callback)
- {
- _isNavigatingInternal = true;
- NavigationTarget.RequestNavigate(
- entry.Uri,
- nr =>
- {
- _isNavigatingInternal = false;
-
- if (nr.Result.HasValue)
- {
- callback(nr.Result.Value);
- }
- },
- entry.Parameters);
- }
-}
diff --git a/src/Maui/Prism.Maui/Regions/Navigation/RegionNavigationJournalEntry.cs b/src/Maui/Prism.Maui/Regions/Navigation/RegionNavigationJournalEntry.cs
deleted file mode 100644
index 7c7f60acc3..0000000000
--- a/src/Maui/Prism.Maui/Regions/Navigation/RegionNavigationJournalEntry.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using System.Globalization;
-using Prism.Navigation;
-
-namespace Prism.Regions.Navigation;
-
-///
-/// An entry in an IRegionNavigationJournal representing the URI navigated to.
-///
-public class RegionNavigationJournalEntry : IRegionNavigationJournalEntry
-{
- ///
- /// Gets or sets the URI.
- ///
- /// The URI.
- public Uri Uri { get; set; }
-
- ///
- /// Gets or sets the NavigationParameters instance.
- ///
- public INavigationParameters Parameters { get; set; }
-
- ///
- /// Returns a that represents this instance.
- ///
- ///
- /// A that represents this instance.
- ///
- public override string ToString()
- {
- if (Uri != null)
- {
- return string.Format(CultureInfo.CurrentCulture, "RegionNavigationJournalEntry:'{0}'", Uri.ToString());
- }
-
- return base.ToString();
- }
-}
diff --git a/src/Maui/Prism.Maui/Regions/Navigation/RegionNavigationResult.cs b/src/Maui/Prism.Maui/Regions/Navigation/RegionNavigationResult.cs
deleted file mode 100644
index b14f6a6213..0000000000
--- a/src/Maui/Prism.Maui/Regions/Navigation/RegionNavigationResult.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-namespace Prism.Regions.Navigation;
-
-///
-/// Represents the result of navigating to a URI.
-///
-public class RegionNavigationResult : IRegionNavigationResult
-{
- ///
- /// Initializes a new instance of the class.
- ///
- /// The context.
- /// The result.
- public RegionNavigationResult(INavigationContext context, bool? result)
- {
- Context = context;
- Result = result;
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The context.
- /// The error.
- public RegionNavigationResult(INavigationContext context, Exception error)
- {
- Context = context;
- Error = error;
- Result = false;
- }
-
- ///
- /// Gets the result.
- ///
- /// The result.
- public bool? Result { get; }
-
- ///
- /// Gets an exception that occurred while navigating.
- ///
- /// The exception.
- public Exception Error { get; }
-
- ///
- /// Gets the navigation context.
- ///
- /// The navigation context.
- public INavigationContext Context { get; }
-}
diff --git a/src/Maui/Prism.Maui/Regions/RegionMemberLifetimeAttribute.cs b/src/Maui/Prism.Maui/Regions/RegionMemberLifetimeAttribute.cs
deleted file mode 100644
index bf23ae306b..0000000000
--- a/src/Maui/Prism.Maui/Regions/RegionMemberLifetimeAttribute.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using Prism.Regions.Behaviors;
-
-namespace Prism.Regions;
-
-///
-/// When is applied to class provides data
-/// the can use to determine if the instance should
-/// be removed when it is deactivated.
-///
-[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true, Inherited = true)]
-public sealed class RegionMemberLifetimeAttribute : Attribute
-{
- ///
- /// Instantiates an instance of
- ///
- public RegionMemberLifetimeAttribute()
- {
- KeepAlive = true;
- }
-
- ///
- /// Determines if the region member should be kept-alive
- /// when deactivated.
- ///
- public bool KeepAlive { get; set; }
-}
diff --git a/src/Maui/Prism.Maui/Regions/SyncActiveStateAttribute.cs b/src/Maui/Prism.Maui/Regions/SyncActiveStateAttribute.cs
deleted file mode 100644
index bd2df43f28..0000000000
--- a/src/Maui/Prism.Maui/Regions/SyncActiveStateAttribute.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace Prism.Regions;
-
-///
-/// Defines that a view is synchronized with its parent view's Active state.
-///
-[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
-public sealed class SyncActiveStateAttribute : Attribute
-{
-}
diff --git a/src/Maui/Prism.Maui/Regions/UpdateRegionsException.cs b/src/Maui/Prism.Maui/Regions/UpdateRegionsException.cs
deleted file mode 100644
index 5620511432..0000000000
--- a/src/Maui/Prism.Maui/Regions/UpdateRegionsException.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using System.Runtime.Serialization;
-
-namespace Prism.Regions;
-
-///
-/// Represents errors that occured during the regions' update.
-///
-[Serializable]
-public class UpdateRegionsException : Exception
-{
- ///
- /// Initializes a new instance of the
- ///
- public UpdateRegionsException()
- {
- }
-
- ///
- /// Initializes a new instance of the class with a specified error message.
- ///
- /// The message that describes the error.
- public UpdateRegionsException(string message)
- : base(message)
- {
- }
-
- ///
- /// Initializes a new instance of the class with a specified error message and a reference
- /// to the inner exception that is the cause of this exception.
- ///
- /// The error message that explains the reason for the exception.
- /// The exception that is the cause of the current exception, or a null reference
- /// (Nothing in Visual Basic) if no inner exception is specified.
- public UpdateRegionsException(string message, Exception inner)
- : base(message, inner)
- {
- }
-
- ///
- /// Initializes a new instance of the class with serialized data.
- ///
- /// The that holds the serialized object data about the exception being thrown.
- /// The that contains contextual information about the source or destination.
- protected UpdateRegionsException(SerializationInfo info, StreamingContext context)
- : base(info, context)
- {
- }
-}
diff --git a/src/Maui/Prism.Maui/Regions/ViewRegisteredEventArgs.cs b/src/Maui/Prism.Maui/Regions/ViewRegisteredEventArgs.cs
deleted file mode 100644
index d0b29c82e1..0000000000
--- a/src/Maui/Prism.Maui/Regions/ViewRegisteredEventArgs.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using Prism.Ioc;
-
-namespace Prism.Regions;
-
-///
-/// Argument class used by the event when a new content is registered.
-///
-public class ViewRegisteredEventArgs : EventArgs
-{
- ///
- /// Initializes the ViewRegisteredEventArgs class.
- ///
- /// The region name to which the content was registered.
- /// The content which was registered.
- public ViewRegisteredEventArgs(string regionName, Func getViewDelegate)
- {
- GetView = getViewDelegate;
- RegionName = regionName;
- }
-
- ///
- /// Gets the region name to which the content was registered.
- ///
- public string RegionName { get; private set; }
-
- ///
- /// Gets the content which was registered.
- ///
- public Func GetView { get; private set; }
-}
diff --git a/src/Maui/Prism.Maui/Regions/ViewRegistrationException.cs b/src/Maui/Prism.Maui/Regions/ViewRegistrationException.cs
deleted file mode 100644
index 5384747c4b..0000000000
--- a/src/Maui/Prism.Maui/Regions/ViewRegistrationException.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-using System.Runtime.Serialization;
-
-namespace Prism.Regions;
-
-///
-/// Exception that's thrown when something goes wrong while Registering a View with a region name in the class.
-///
-[Serializable]
-public class ViewRegistrationException : Exception
-{
- // TODO: Find updated links as these are dead...
- //
- // For guidelines regarding the creation of new exception types, see
- // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp
- // and
- // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp
- //
-
- ///
- /// Initializes a new instance of the class.
- ///
- public ViewRegistrationException()
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The exception message.
- public ViewRegistrationException(string message) : base(message)
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The exception message.
- /// The inner exception.
- public ViewRegistrationException(string message, Exception inner) : base(message, inner)
- {
- }
-
- ///
- /// Initializes a new instance of the class with serialized data.
- ///
- /// The that holds the serialized
- /// object data about the exception being thrown.
- /// The that contains contextual information about the source or destination.
- protected ViewRegistrationException(SerializationInfo info, StreamingContext context)
- : base(info, context)
- {
- }
-}
\ No newline at end of file
diff --git a/src/Maui/Prism.Maui/Regions/ViewSortHintAttribute.cs b/src/Maui/Prism.Maui/Regions/ViewSortHintAttribute.cs
deleted file mode 100644
index 74a42cc5bd..0000000000
--- a/src/Maui/Prism.Maui/Regions/ViewSortHintAttribute.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-namespace Prism.Regions;
-
-///
-/// Provides a hint from a view to a region on how to sort the view.
-///
-[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
-public sealed class ViewSortHintAttribute : Attribute
-{
- ///
- /// Initializes a new instance of the class.
- ///
- /// The hint to use for sorting.
- public ViewSortHintAttribute(string hint)
- {
- Hint = hint;
- }
-
- ///
- /// Gets the hint.
- ///
- /// The hint to use for sorting.
- public string Hint { get; }
-}
diff --git a/src/Maui/Prism.Maui/build/Package.targets b/src/Maui/Prism.Maui/build/Package.targets
new file mode 100644
index 0000000000..5619b83c28
--- /dev/null
+++ b/src/Maui/Prism.Maui/build/Package.targets
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/src/Maui/Prism.Maui/build/Prism.Maui.targets b/src/Maui/Prism.Maui/build/Prism.Maui.targets
deleted file mode 100644
index 20a6b2ff5a..0000000000
--- a/src/Maui/Prism.Maui/build/Prism.Maui.targets
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Prism.Core/Navigation/INavigationResult.cs b/src/Prism.Core/Navigation/INavigationResult.cs
new file mode 100644
index 0000000000..defbfadd0e
--- /dev/null
+++ b/src/Prism.Core/Navigation/INavigationResult.cs
@@ -0,0 +1,32 @@
+using System;
+using Prism.Navigation.Regions;
+
+namespace Prism.Navigation;
+
+#nullable enable
+///
+/// Provides a wrapper for a Navigation Result
+///
+public interface INavigationResult
+{
+ ///
+ /// Indicates that the navigation was successful and no Navigation Errors occurred
+ ///
+ bool Success { get; }
+
+ ///
+ /// If true this indicates that the Navigation Event was cancelled.
+ ///
+ bool Cancelled { get; }
+
+ ///
+ /// The Exception if one occurred.
+ ///
+ Exception? Exception { get; }
+
+ ///
+ /// If the is the result of Region Navigation
+ /// This will provide the associate
+ ///
+ NavigationContext? Context { get; }
+}
diff --git a/src/Maui/Prism.Maui/Navigation/NavigationException.cs b/src/Prism.Core/Navigation/NavigationException.cs
similarity index 85%
rename from src/Maui/Prism.Maui/Navigation/NavigationException.cs
rename to src/Prism.Core/Navigation/NavigationException.cs
index 848c671432..d8fefebe07 100644
--- a/src/Maui/Prism.Maui/Navigation/NavigationException.cs
+++ b/src/Prism.Core/Navigation/NavigationException.cs
@@ -1,3 +1,5 @@
+using System;
+
namespace Prism.Navigation;
public class NavigationException : Exception
@@ -25,7 +27,7 @@ public NavigationException(string message)
{
}
- public NavigationException(string message, VisualElement view)
+ public NavigationException(string message, object view)
: this(message, view, null)
{
}
@@ -40,18 +42,24 @@ public NavigationException(string message, string navigationKey, Exception inner
{
}
- public NavigationException(string message, VisualElement view, Exception innerException)
+ public NavigationException(string message, object view, Exception innerException)
: this(message, null, view, innerException)
{
}
- public NavigationException(string message, string navigationKey, VisualElement view, Exception innerException) : base(message, innerException)
+ public NavigationException(string message, string navigationKey, object view, Exception innerException) : base(message, innerException)
{
View = view;
NavigationKey = navigationKey;
}
- public VisualElement View { get; }
+ ///
+ /// The View Instance
+ ///
+ public object View { get; }
+ ///
+ /// The key used for the failed navigation
+ ///
public string NavigationKey { get; }
-}
\ No newline at end of file
+}
diff --git a/src/Prism.Core/Navigation/NavigationResult.cs b/src/Prism.Core/Navigation/NavigationResult.cs
new file mode 100644
index 0000000000..19318edfdc
--- /dev/null
+++ b/src/Prism.Core/Navigation/NavigationResult.cs
@@ -0,0 +1,74 @@
+using System;
+using Prism.Navigation.Regions;
+
+namespace Prism.Navigation;
+
+#nullable enable
+///
+/// Default implementation for the
+///
+public class NavigationResult : INavigationResult
+{
+ private readonly bool? _success;
+
+ ///
+ /// Initializes a new Navigation Result
+ ///
+ public NavigationResult()
+ {
+ }
+
+ ///
+ /// Initializes a new NavigationResult
+ ///
+ ///
+ public NavigationResult(bool success)
+ {
+ _success = success;
+ }
+
+ ///
+ /// Initializes a new NavigationResult with an
+ ///
+ /// The encountered as part of the navigation.
+ public NavigationResult(Exception ex)
+ {
+ Exception = ex;
+ }
+
+ ///
+ /// Initializes a new NavigationResult
+ ///
+ ///
+ ///
+ public NavigationResult(NavigationContext context, bool success)
+ {
+ Context = context;
+ _success = success;
+ }
+
+ ///
+ /// Initializes a new NavigationResult
+ ///
+ ///
+ ///
+ public NavigationResult(NavigationContext context, Exception exception)
+ {
+ Context = context;
+ Exception = exception;
+ }
+
+ ///
+ public bool Success => _success ?? Exception is null;
+
+ ///
+ public bool Cancelled =>
+ Exception is NavigationException navigationException
+ && navigationException.Message == NavigationException.IConfirmNavigationReturnedFalse;
+
+ ///
+ public Exception? Exception { get; }
+
+ ///
+ public NavigationContext? Context { get; }
+}
diff --git a/src/Wpf/Prism.Wpf/Regions/IConfirmNavigationRequest.cs b/src/Prism.Core/Navigation/Regions/IConfirmNavigationRequest.cs
similarity index 89%
rename from src/Wpf/Prism.Wpf/Regions/IConfirmNavigationRequest.cs
rename to src/Prism.Core/Navigation/Regions/IConfirmNavigationRequest.cs
index dd2f6afa0d..49083b1dd0 100644
--- a/src/Wpf/Prism.Wpf/Regions/IConfirmNavigationRequest.cs
+++ b/src/Prism.Core/Navigation/Regions/IConfirmNavigationRequest.cs
@@ -1,11 +1,11 @@
using System;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Provides a way for objects involved in navigation to determine if a navigation request should continue.
///
- public interface IConfirmNavigationRequest : INavigationAware
+ public interface IConfirmNavigationRequest : IRegionAware
{
///
/// Determines whether this instance accepts being navigated away from.
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Navigation/IJournalAware.cs b/src/Prism.Core/Navigation/Regions/IJournalAware.cs
similarity index 92%
rename from src/Forms/Prism.Forms.Regions/Regions/Navigation/IJournalAware.cs
rename to src/Prism.Core/Navigation/Regions/IJournalAware.cs
index e787724088..446aa4fff7 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/Navigation/IJournalAware.cs
+++ b/src/Prism.Core/Navigation/Regions/IJournalAware.cs
@@ -1,4 +1,4 @@
-namespace Prism.Regions.Navigation
+namespace Prism.Navigation.Regions
{
///
/// Provides a way for objects involved in navigation to opt-out of being added to the IRegionNavigationJournal backstack.
diff --git a/src/Wpf/Prism.Wpf/Regions/INavigateAsync.cs b/src/Prism.Core/Navigation/Regions/INavigateAsync.cs
similarity index 59%
rename from src/Wpf/Prism.Wpf/Regions/INavigateAsync.cs
rename to src/Prism.Core/Navigation/Regions/INavigateAsync.cs
index 4d0d89d014..ccfc23ff9b 100644
--- a/src/Wpf/Prism.Wpf/Regions/INavigateAsync.cs
+++ b/src/Prism.Core/Navigation/Regions/INavigateAsync.cs
@@ -1,28 +1,16 @@
using System;
-using Prism.Navigation;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Provides methods to perform navigation.
///
///
- /// Convenience overloads for the methods in this interface can be found as extension methods on the
+ /// Convenience overloads for the methods in this interface can be found as extension methods on the
/// class.
///
public interface INavigateAsync
{
- ///
- /// Initiates navigation to the target specified by the .
- ///
- /// The navigation target
- /// The callback executed when the navigation request is completed.
- ///
- /// Convenience overloads for this method can be found as extension methods on the
- /// class.
- ///
- void RequestNavigate(Uri target, Action navigationCallback);
-
///
/// Initiates navigation to the target specified by the .
///
@@ -30,7 +18,7 @@ public interface INavigateAsync
/// The callback executed when the navigation request is completed.
/// The navigation parameters specific to the navigation request.
///
- /// Convenience overloads for this method can be found as extension methods on the
+ /// Convenience overloads for this method can be found as extension methods on the
/// class.
///
void RequestNavigate(Uri target, Action navigationCallback, INavigationParameters navigationParameters);
diff --git a/src/Wpf/Prism.Wpf/Regions/IRegion.cs b/src/Prism.Core/Navigation/Regions/IRegion.cs
similarity index 88%
rename from src/Wpf/Prism.Wpf/Regions/IRegion.cs
rename to src/Prism.Core/Navigation/Regions/IRegion.cs
index 9a06685e94..5ff4fe0fc3 100644
--- a/src/Wpf/Prism.Wpf/Regions/IRegion.cs
+++ b/src/Prism.Core/Navigation/Regions/IRegion.cs
@@ -1,15 +1,7 @@
-
-
using System;
using System.ComponentModel;
-#if HAS_WINUI
-using Microsoft.UI.Xaml;
-#else
-using System.Windows;
-#endif
-
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Defines a model that can be used to compose views.
@@ -46,12 +38,20 @@ public interface IRegion : INavigateAsync, INotifyPropertyChanged
/// The comparison to use.
Comparison SortComparison { get; set; }
+ ///Adds a new view to the region.
+ ///
+ /// Adds a new view to the region.
+ ///
+ /// The view to add.
+ /// The that is set on the view. It will be the current region manager when using this overload.
+ IRegionManager Add(string viewName);
+
///Adds a new view to the region.
///
/// Adds a new view to the region.
///
/// The view to add.
- /// The that is set on the view if it is a . It will be the current region manager when using this overload.
+ /// The that is set on the view. It will be the current region manager when using this overload.
IRegionManager Add(object view);
///
@@ -59,7 +59,7 @@ public interface IRegion : INavigateAsync, INotifyPropertyChanged
///
/// The view to add.
/// The name of the view. This can be used to retrieve it later by calling .
- /// The that is set on the view if it is a . It will be the current region manager when using this overload.
+ /// The that is set on the view. It will be the current region manager when using this overload.
IRegionManager Add(object view, string viewName);
///
@@ -68,7 +68,7 @@ public interface IRegion : INavigateAsync, INotifyPropertyChanged
/// The view to add.
/// The name of the view. This can be used to retrieve it later by calling .
/// When , the added view will receive a new instance of , otherwise it will use the current region manager for this region.
- /// The that is set on the view if it is a .
+ /// The that is set on the view.
IRegionManager Add(object view, string viewName, bool createRegionManagerScope);
///
diff --git a/src/Wpf/Prism.Wpf/Regions/IRegionAdapter.cs b/src/Prism.Core/Navigation/Regions/IRegionAdapter.cs
similarity index 94%
rename from src/Wpf/Prism.Wpf/Regions/IRegionAdapter.cs
rename to src/Prism.Core/Navigation/Regions/IRegionAdapter.cs
index 3b68511a2b..455b186a20 100644
--- a/src/Wpf/Prism.Wpf/Regions/IRegionAdapter.cs
+++ b/src/Prism.Core/Navigation/Regions/IRegionAdapter.cs
@@ -1,7 +1,4 @@
-
-
-
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Defines an interfaces to adapt an object and bind it to a new .
diff --git a/src/Wpf/Prism.Wpf/Regions/INavigationAware.cs b/src/Prism.Core/Navigation/Regions/IRegionAware.cs
similarity index 94%
rename from src/Wpf/Prism.Wpf/Regions/INavigationAware.cs
rename to src/Prism.Core/Navigation/Regions/IRegionAware.cs
index 9592370372..ce6f51e2a9 100644
--- a/src/Wpf/Prism.Wpf/Regions/INavigationAware.cs
+++ b/src/Prism.Core/Navigation/Regions/IRegionAware.cs
@@ -1,12 +1,9 @@
-
-
-
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Provides a way for objects involved in navigation to be notified of navigation activities.
///
- public interface INavigationAware
+ public interface IRegionAware
{
///
/// Called when the implementer has been navigated to.
diff --git a/src/Wpf/Prism.Wpf/Regions/IRegionBehavior.cs b/src/Prism.Core/Navigation/Regions/IRegionBehavior.cs
similarity index 92%
rename from src/Wpf/Prism.Wpf/Regions/IRegionBehavior.cs
rename to src/Prism.Core/Navigation/Regions/IRegionBehavior.cs
index b35ba49c76..efd0af3e2f 100644
--- a/src/Wpf/Prism.Wpf/Regions/IRegionBehavior.cs
+++ b/src/Prism.Core/Navigation/Regions/IRegionBehavior.cs
@@ -1,6 +1,4 @@
-
-
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Interface for allowing extensible behavior on regions.
@@ -16,6 +14,5 @@ public interface IRegionBehavior
/// Attaches the behavior to the specified region.
///
void Attach();
-
}
}
diff --git a/src/Wpf/Prism.Wpf/Regions/IRegionBehaviorCollection.cs b/src/Prism.Core/Navigation/Regions/IRegionBehaviorCollection.cs
similarity index 89%
rename from src/Wpf/Prism.Wpf/Regions/IRegionBehaviorCollection.cs
rename to src/Prism.Core/Navigation/Regions/IRegionBehaviorCollection.cs
index e75373357e..7f7e82a5c1 100644
--- a/src/Wpf/Prism.Wpf/Regions/IRegionBehaviorCollection.cs
+++ b/src/Prism.Core/Navigation/Regions/IRegionBehaviorCollection.cs
@@ -1,8 +1,6 @@
-
-
using System.Collections.Generic;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Defines the interface for a collection of classes on a Region.
@@ -11,16 +9,16 @@ public interface IRegionBehaviorCollection : IEnumerable
- /// Adds a to the collection, using the specified key as an indexer.
+ /// Adds a to the collection, using the specified key as an indexer.
///
///
- /// The key that specifies the type of that's added.
+ /// The key that specifies the type of that's added.
///
/// The to add.
void Add(string key, IRegionBehavior regionBehavior);
///
- /// Checks if a with the specified key is already present.
+ /// Checks if a with the specified key is already present.
///
/// The key to use to find a particular .
///
diff --git a/src/Wpf/Prism.Wpf/Regions/IRegionBehaviorFactory.cs b/src/Prism.Core/Navigation/Regions/IRegionBehaviorFactory.cs
similarity index 88%
rename from src/Wpf/Prism.Wpf/Regions/IRegionBehaviorFactory.cs
rename to src/Prism.Core/Navigation/Regions/IRegionBehaviorFactory.cs
index 2a0b35e1aa..2ce6ab0ecc 100644
--- a/src/Wpf/Prism.Wpf/Regions/IRegionBehaviorFactory.cs
+++ b/src/Prism.Core/Navigation/Regions/IRegionBehaviorFactory.cs
@@ -1,15 +1,12 @@
-
-
using System;
using System.Collections.Generic;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Interface for RegionBehaviorFactories. This factory allows the registration of the default set of RegionBehaviors, that will
- /// be added to the s of all s, unless overridden on a 'per-region' basis.
+ /// be added to the s of all s, unless overridden on a 'per-region' basis.
///
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix", Justification = "It is more of a factory than a collection")]
public interface IRegionBehaviorFactory : IEnumerable
{
///
diff --git a/src/Wpf/Prism.Wpf/Regions/IRegionBehaviorFactoryExtensions.cs b/src/Prism.Core/Navigation/Regions/IRegionBehaviorFactoryExtensions.cs
similarity index 59%
rename from src/Wpf/Prism.Wpf/Regions/IRegionBehaviorFactoryExtensions.cs
rename to src/Prism.Core/Navigation/Regions/IRegionBehaviorFactoryExtensions.cs
index 4fdfae878d..0659fe7502 100644
--- a/src/Wpf/Prism.Wpf/Regions/IRegionBehaviorFactoryExtensions.cs
+++ b/src/Prism.Core/Navigation/Regions/IRegionBehaviorFactoryExtensions.cs
@@ -1,10 +1,21 @@
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Extension methods for the IRegionBehaviorFactory.
///
public static class IRegionBehaviorFactoryExtensions
{
+ ///
+ /// Adds a particular type of RegionBehavior if it was not already registered. the Type Name is used to check if the behavior is already present
+ ///
+ /// Type of the behavior to add.
+ /// The IRegionBehaviorFactory instance
+ public static void AddIfMissing(this IRegionBehaviorFactory regionBehaviorFactory) where T : IRegionBehavior
+ {
+ var behaviorType = typeof(T);
+ regionBehaviorFactory.AddIfMissing(typeof(T).Name, behaviorType);
+ }
+
///
/// Adds a particular type of RegionBehavior if it was not already registered. the string is used to check if the behavior is already present
///
diff --git a/src/Wpf/Prism.Wpf/Regions/IRegionCollection.cs b/src/Prism.Core/Navigation/Regions/IRegionCollection.cs
similarity index 93%
rename from src/Wpf/Prism.Wpf/Regions/IRegionCollection.cs
rename to src/Prism.Core/Navigation/Regions/IRegionCollection.cs
index e389752509..d24a1db191 100644
--- a/src/Wpf/Prism.Wpf/Regions/IRegionCollection.cs
+++ b/src/Prism.Core/Navigation/Regions/IRegionCollection.cs
@@ -1,10 +1,8 @@
-
-
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Defines a collection of uniquely identified by their Name.
@@ -39,10 +37,10 @@ public interface IRegionCollection : IEnumerable, INotifyCollectionChan
bool ContainsRegionWithName(string regionName);
///
- /// Adds a region to the with the name received as argument.
+ /// Adds a region to the with the name received as argument.
///
/// The name to be given to the region.
- /// The region to be added to the .
+ /// The region to be added to the .
/// Thrown if is .
/// Thrown if and 's name do not match and the is not .
void Add(string regionName, IRegion region);
diff --git a/src/Wpf/Prism.Wpf/Regions/IRegionManager.cs b/src/Prism.Core/Navigation/Regions/IRegionManager.cs
similarity index 54%
rename from src/Wpf/Prism.Wpf/Regions/IRegionManager.cs
rename to src/Prism.Core/Navigation/Regions/IRegionManager.cs
index 0d7c0b55a2..a977465570 100644
--- a/src/Wpf/Prism.Wpf/Regions/IRegionManager.cs
+++ b/src/Prism.Core/Navigation/Regions/IRegionManager.cs
@@ -1,7 +1,8 @@
using System;
+using Prism.Ioc;
using Prism.Navigation;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Defines an interface to manage a set of regions and to attach regions to objects (typically controls).
@@ -63,37 +64,7 @@ public interface IRegionManager
/// The name of the region to associate the view with.
/// The delegate used to resolve a concrete instance of the view.
/// The , for adding several views easily
- IRegionManager RegisterViewWithRegion(string regionName, Func getContentDelegate);
-
- ///
- /// Navigates the specified region manager.
- ///
- /// The name of the region to call Navigate on.
- /// The URI of the content to display.
- /// The navigation callback.
- void RequestNavigate(string regionName, Uri source, Action navigationCallback);
-
- ///
- /// Navigates the specified region manager.
- ///
- /// The name of the region to call Navigate on.
- /// The URI of the content to display.
- void RequestNavigate(string regionName, Uri source);
-
- ///
- /// Navigates the specified region manager.
- ///
- /// The name of the region to call Navigate on.
- /// The URI of the content to display.
- /// The navigation callback.
- void RequestNavigate(string regionName, string source, Action navigationCallback);
-
- ///
- /// Navigates the specified region manager.
- ///
- /// The name of the region to call Navigate on.
- /// The URI of the content to display.
- void RequestNavigate(string regionName, string source);
+ IRegionManager RegisterViewWithRegion(string regionName, Func getContentDelegate);
///
/// This method allows an IRegionManager to locate a specified region and navigate in it to the specified target Uri, passing a navigation callback and an instance of NavigationParameters, which holds a collection of object parameters.
@@ -103,30 +74,5 @@ public interface IRegionManager
/// The navigation callback that will be executed after the navigation is completed.
/// An instance of NavigationParameters, which holds a collection of object parameters.
void RequestNavigate(string regionName, Uri target, Action navigationCallback, INavigationParameters navigationParameters);
-
- ///
- /// This method allows an IRegionManager to locate a specified region and navigate in it to the specified target string, passing a navigation callback and an instance of NavigationParameters, which holds a collection of object parameters.
- ///
- /// The name of the region where the navigation will occur.
- /// A string that represents the target where the region will navigate.
- /// The navigation callback that will be executed after the navigation is completed.
- /// An instance of NavigationParameters, which holds a collection of object parameters.
- void RequestNavigate(string regionName, string target, Action navigationCallback, INavigationParameters navigationParameters);
-
- ///
- /// This method allows an IRegionManager to locate a specified region and navigate in it to the specified target Uri, passing an instance of NavigationParameters, which holds a collection of object parameters.
- ///
- /// The name of the region where the navigation will occur.
- /// A Uri that represents the target where the region will navigate.
- /// An instance of NavigationParameters, which holds a collection of object parameters.
- void RequestNavigate(string regionName, Uri target, INavigationParameters navigationParameters);
-
- ///
- /// This method allows an IRegionManager to locate a specified region and navigate in it to the specified target string, passing an instance of NavigationParameters, which holds a collection of object parameters.
- ///
- /// The name of the region where the navigation will occur.
- /// A string that represents the target where the region will navigate.
- /// An instance of NavigationParameters, which holds a collection of object parameters.
- void RequestNavigate(string regionName, string target, INavigationParameters navigationParameters);
}
}
diff --git a/src/Prism.Core/Navigation/Regions/IRegionManagerExtensions.cs b/src/Prism.Core/Navigation/Regions/IRegionManagerExtensions.cs
new file mode 100644
index 0000000000..87aad75fdd
--- /dev/null
+++ b/src/Prism.Core/Navigation/Regions/IRegionManagerExtensions.cs
@@ -0,0 +1,104 @@
+using System;
+using Prism.Navigation;
+
+namespace Prism.Navigation.Regions
+{
+ ///
+ /// Common Extensions for the RegionManager
+ ///
+ public static class IRegionManagerExtensions
+ {
+ ///
+ /// Associate a view with a region, using a delegate to resolve a concrete instance of the view.
+ /// When the region gets displayed, this delegate will be called and the result will be added to the
+ /// views collection of the region.
+ ///
+ /// The current .
+ /// The name of the region to associate the view with.
+ /// The delegate used to resolve a concrete instance of the view.
+ /// The , for adding several views easily
+ public static IRegionManager RegisterViewWithRegion(this IRegionManager regionManager, string regionName, Func getContentDelegate) =>
+ regionManager.RegisterViewWithRegion(regionName, _ => getContentDelegate());
+
+ ///
+ /// Associate a view with a region, by registering a type. When the region get's displayed
+ /// this type will be resolved using the ServiceLocator into a concrete instance. The instance
+ /// will be added to the Views collection of the region
+ ///
+ /// The type of the view to register with the .
+ /// The current .
+ /// The name of the region to associate the view with.
+ /// The , for adding several views easily
+ public static IRegionManager RegisterViewWithRegion(this IRegionManager regionManager, string regionName) =>
+ regionManager.RegisterViewWithRegion(regionName, typeof(T));
+
+ ///
+ /// Navigates the specified region manager.
+ ///
+ /// The current .
+ /// The name of the region to call Navigate on.
+ /// The URI of the content to display.
+ public static void RequestNavigate(this IRegionManager regionManager, string regionName, Uri source) =>
+ regionManager.RequestNavigate(regionName, source, _ => { }, new NavigationParameters());
+
+ ///
+ /// Navigates the specified region manager.
+ ///
+ /// The current .
+ /// The name of the region to call Navigate on.
+ /// The URI of the content to display.
+ /// The navigation callback.
+ public static void RequestNavigate(this IRegionManager regionManager, string regionName, Uri source, Action navigationCallback) =>
+ regionManager.RequestNavigate(regionName, source, navigationCallback, new NavigationParameters());
+
+ ///
+ /// Navigates the specified region manager.
+ ///
+ /// The current .
+ /// The name of the region to call Navigate on.
+ /// The URI of the content to display.
+ /// The navigation callback.
+ public static void RequestNavigate(this IRegionManager regionManager, string regionName, string source, Action navigationCallback) =>
+ regionManager.RequestNavigate(regionName, new Uri(source, UriKind.RelativeOrAbsolute), navigationCallback, new NavigationParameters());
+
+ ///
+ /// Navigates the specified region manager.
+ ///
+ /// The current .
+ /// The name of the region to call Navigate on.
+ /// The URI of the content to display.
+ public static void RequestNavigate(this IRegionManager regionManager, string regionName, string source) =>
+ regionManager.RequestNavigate(regionName, new Uri(source, UriKind.RelativeOrAbsolute), _ => { }, new NavigationParameters());
+
+ ///
+ /// This method allows an IRegionManager to locate a specified region and navigate in it to the specified target string, passing a navigation callback and an instance of NavigationParameters, which holds a collection of object parameters.
+ ///
+ /// The current .
+ /// The name of the region where the navigation will occur.
+ /// A string that represents the target where the region will navigate.
+ /// The navigation callback that will be executed after the navigation is completed.
+ /// An instance of NavigationParameters, which holds a collection of object parameters.
+ public static void RequestNavigate(this IRegionManager regionManager, string regionName, string target, Action navigationCallback, INavigationParameters navigationParameters) =>
+ regionManager.RequestNavigate(regionName, new Uri(target, UriKind.RelativeOrAbsolute), navigationCallback, navigationParameters);
+
+ ///
+ /// This method allows an IRegionManager to locate a specified region and navigate in it to the specified target Uri, passing an instance of NavigationParameters, which holds a collection of object parameters.
+ ///
+ /// The current .
+ /// The name of the region where the navigation will occur.
+ /// A Uri that represents the target where the region will navigate.
+ /// An instance of NavigationParameters, which holds a collection of object parameters.
+ public static void RequestNavigate(this IRegionManager regionManager, string regionName, Uri target, INavigationParameters navigationParameters) =>
+ regionManager.RequestNavigate(regionName, target, _ => { }, navigationParameters);
+
+ ///
+ /// This method allows an IRegionManager to locate a specified region and navigate in it to the specified target string, passing an instance of NavigationParameters, which holds a collection of object parameters.
+ ///
+ /// The current .
+ /// The name of the region where the navigation will occur.
+ /// A string that represents the target where the region will navigate.
+ /// An instance of NavigationParameters, which holds a collection of object parameters.
+ public static void RequestNavigate(this IRegionManager regionManager, string regionName, string target, INavigationParameters navigationParameters) =>
+ regionManager.RequestNavigate(regionName, new Uri(target, UriKind.RelativeOrAbsolute), navigationParameters);
+ }
+}
diff --git a/src/Wpf/Prism.Wpf/Regions/IRegionMemberLifetime.cs b/src/Prism.Core/Navigation/Regions/IRegionMemberLifetime.cs
similarity index 77%
rename from src/Wpf/Prism.Wpf/Regions/IRegionMemberLifetime.cs
rename to src/Prism.Core/Navigation/Regions/IRegionMemberLifetime.cs
index e8d1036c71..bc2ab7c760 100644
--- a/src/Wpf/Prism.Wpf/Regions/IRegionMemberLifetime.cs
+++ b/src/Prism.Core/Navigation/Regions/IRegionMemberLifetime.cs
@@ -1,10 +1,8 @@
-using Prism.Regions.Behaviors;
-
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// When implemented, allows an instance placed in a
- /// that uses a to indicate
+ /// that uses a RegionMemberLifetimeBehavior to indicate
/// it should be removed when it transitions from an activated to deactivated state.
///
public interface IRegionMemberLifetime
diff --git a/src/Wpf/Prism.Wpf/Regions/IRegionNavigationContentLoader.cs b/src/Prism.Core/Navigation/Regions/IRegionNavigationContentLoader.cs
similarity index 96%
rename from src/Wpf/Prism.Wpf/Regions/IRegionNavigationContentLoader.cs
rename to src/Prism.Core/Navigation/Regions/IRegionNavigationContentLoader.cs
index a43fb6caf2..a2553e591e 100644
--- a/src/Wpf/Prism.Wpf/Regions/IRegionNavigationContentLoader.cs
+++ b/src/Prism.Core/Navigation/Regions/IRegionNavigationContentLoader.cs
@@ -1,8 +1,6 @@
-
-
using System;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Identifies the view in a region that is the target of a navigation request.
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Navigation/IRegionNavigationJournal.cs b/src/Prism.Core/Navigation/Regions/IRegionNavigationJournal.cs
similarity index 93%
rename from src/Forms/Prism.Forms.Regions/Regions/Navigation/IRegionNavigationJournal.cs
rename to src/Prism.Core/Navigation/Regions/IRegionNavigationJournal.cs
index 84dffdb2ef..f7709e74ab 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/Navigation/IRegionNavigationJournal.cs
+++ b/src/Prism.Core/Navigation/Regions/IRegionNavigationJournal.cs
@@ -1,4 +1,4 @@
-namespace Prism.Regions.Navigation
+namespace Prism.Navigation.Regions
{
///
/// Provides journaling of current, back, and forward navigation within regions.
@@ -50,7 +50,7 @@ public interface IRegionNavigationJournal
/// Records the navigation to the entry..
///
/// The entry to record.
- /// true if you it should be persisted in history
+ /// Keep Navigation object in memory when OnNavigationFrom is called
void RecordNavigation(IRegionNavigationJournalEntry entry, bool persistInHistory);
///
diff --git a/src/Wpf/Prism.Wpf/Regions/IRegionNavigationJournalEntry.cs b/src/Prism.Core/Navigation/Regions/IRegionNavigationJournalEntry.cs
similarity index 93%
rename from src/Wpf/Prism.Wpf/Regions/IRegionNavigationJournalEntry.cs
rename to src/Prism.Core/Navigation/Regions/IRegionNavigationJournalEntry.cs
index ae04db3d8a..7226e23482 100644
--- a/src/Wpf/Prism.Wpf/Regions/IRegionNavigationJournalEntry.cs
+++ b/src/Prism.Core/Navigation/Regions/IRegionNavigationJournalEntry.cs
@@ -1,7 +1,7 @@
using System;
using Prism.Navigation;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// An entry in an IRegionNavigationJournal representing the URI navigated to.
diff --git a/src/Maui/Prism.Maui/Regions/IRegionNavigationRegistry.cs b/src/Prism.Core/Navigation/Regions/IRegionNavigationRegistry.cs
similarity index 70%
rename from src/Maui/Prism.Maui/Regions/IRegionNavigationRegistry.cs
rename to src/Prism.Core/Navigation/Regions/IRegionNavigationRegistry.cs
index c3470312d2..e82a602cb9 100644
--- a/src/Maui/Prism.Maui/Regions/IRegionNavigationRegistry.cs
+++ b/src/Prism.Core/Navigation/Regions/IRegionNavigationRegistry.cs
@@ -1,5 +1,5 @@
using Prism.Mvvm;
-namespace Prism.Regions;
+namespace Prism.Navigation.Regions;
public interface IRegionNavigationRegistry : IViewRegistry { }
diff --git a/src/Wpf/Prism.Wpf/Regions/IRegionNavigationService.cs b/src/Prism.Core/Navigation/Regions/IRegionNavigationService.cs
similarity index 96%
rename from src/Wpf/Prism.Wpf/Regions/IRegionNavigationService.cs
rename to src/Prism.Core/Navigation/Regions/IRegionNavigationService.cs
index a4776d439d..dff55aa253 100644
--- a/src/Wpf/Prism.Wpf/Regions/IRegionNavigationService.cs
+++ b/src/Prism.Core/Navigation/Regions/IRegionNavigationService.cs
@@ -1,8 +1,6 @@
-
-
using System;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Provides navigation for regions.
diff --git a/src/Wpf/Prism.Wpf/Regions/IRegionViewRegistry.cs b/src/Prism.Core/Navigation/Regions/IRegionViewRegistry.cs
similarity index 61%
rename from src/Wpf/Prism.Wpf/Regions/IRegionViewRegistry.cs
rename to src/Prism.Core/Navigation/Regions/IRegionViewRegistry.cs
index b4c3af4f68..9f0af013a1 100644
--- a/src/Wpf/Prism.Wpf/Regions/IRegionViewRegistry.cs
+++ b/src/Prism.Core/Navigation/Regions/IRegionViewRegistry.cs
@@ -1,7 +1,8 @@
using System;
using System.Collections.Generic;
+using Prism.Ioc;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Defines the interface for the registry of region's content.
@@ -21,8 +22,19 @@ public interface IRegionViewRegistry
/// Returns the contents associated with a region name.
///
/// Region name for which contents are requested.
+ /// The to use to resolve the View.
/// Collection of contents associated with the .
- IEnumerable GetContents(string regionName);
+ IEnumerable GetContents(string regionName, IContainerProvider container);
+
+ ///
+ /// Associate a view with a region, by registering a type. When the region get's displayed
+ /// this type will be resolved using the ServiceLocator into a concrete instance. The instance
+ /// will be added to the Views collection of the region
+ ///
+ /// The name of the region to associate the view with.
+ /// The type of the view to register with the
+ /// The , for adding several views easily
+ void RegisterViewWithRegion(string regionName, string targetName);
///
/// Registers a content type with a region name.
@@ -32,10 +44,10 @@ public interface IRegionViewRegistry
void RegisterViewWithRegion(string regionName, Type viewType);
///
- /// Registers a delegate that can be used to retrieve the content associated with a region name.
+ /// Registers a delegate that can be used to retrieve the content associated with a region name.
///
/// Region name to which the will be registered.
/// Delegate used to retrieve the content associated with the .
- void RegisterViewWithRegion(string regionName, Func getContentDelegate);
+ public void RegisterViewWithRegion(string regionName, Func getContentDelegate);
}
}
diff --git a/src/Wpf/Prism.Wpf/Regions/IViewsCollection.cs b/src/Prism.Core/Navigation/Regions/IViewsCollection.cs
similarity index 94%
rename from src/Wpf/Prism.Wpf/Regions/IViewsCollection.cs
rename to src/Prism.Core/Navigation/Regions/IViewsCollection.cs
index 0dc39138d0..d7974de538 100644
--- a/src/Wpf/Prism.Wpf/Regions/IViewsCollection.cs
+++ b/src/Prism.Core/Navigation/Regions/IViewsCollection.cs
@@ -1,9 +1,7 @@
-
-
using System.Collections.Generic;
using System.Collections.Specialized;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Defines a view of a collection.
diff --git a/src/Wpf/Prism.Wpf/Regions/NavigationAsyncExtensions.cs b/src/Prism.Core/Navigation/Regions/NavigationAsyncExtensions.cs
similarity index 85%
rename from src/Wpf/Prism.Wpf/Regions/NavigationAsyncExtensions.cs
rename to src/Prism.Core/Navigation/Regions/NavigationAsyncExtensions.cs
index e4d13a40b5..07f380c365 100644
--- a/src/Wpf/Prism.Wpf/Regions/NavigationAsyncExtensions.cs
+++ b/src/Prism.Core/Navigation/Regions/NavigationAsyncExtensions.cs
@@ -1,13 +1,26 @@
using System;
using Prism.Navigation;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Provides additional methods to the interface.
///
public static class NavigationAsyncExtensions
{
+ ///
+ /// Initiates navigation to the target specified by the .
+ ///
+ /// The navigation object.
+ /// The navigation target
+ /// The callback executed when the navigation request is completed.
+ ///
+ /// Convenience overloads for this method can be found as extension methods on the
+ /// class.
+ ///
+ public static void RequestNavigate(this INavigateAsync navigation, Uri target, Action navigationCallback) =>
+ navigation.RequestNavigate(target, navigationCallback, new NavigationParameters());
+
///
/// Initiates navigation to the target specified by the .
///
diff --git a/src/Wpf/Prism.Wpf/Regions/NavigationContext.cs b/src/Prism.Core/Navigation/Regions/NavigationContext.cs
similarity index 95%
rename from src/Wpf/Prism.Wpf/Regions/NavigationContext.cs
rename to src/Prism.Core/Navigation/Regions/NavigationContext.cs
index 7cac314efc..b39d15a016 100644
--- a/src/Wpf/Prism.Wpf/Regions/NavigationContext.cs
+++ b/src/Prism.Core/Navigation/Regions/NavigationContext.cs
@@ -3,7 +3,7 @@
using Prism.Common;
using Prism.Navigation;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Encapsulates information about a navigation request.
@@ -11,7 +11,7 @@ namespace Prism.Regions
public class NavigationContext
{
///
- /// Initializes a new instance of the class for a region name and a
+ /// Initializes a new instance of the class for a region name and a
/// .
///
/// The navigation service.
@@ -21,7 +21,7 @@ public NavigationContext(IRegionNavigationService navigationService, Uri uri) :
}
///
- /// Initializes a new instance of the class for a region name and a
+ /// Initializes a new instance of the class for a region name and a
/// .
///
/// The navigation service.
diff --git a/src/Prism.Core/Navigation/Regions/NavigationContextExtensions.cs b/src/Prism.Core/Navigation/Regions/NavigationContextExtensions.cs
new file mode 100644
index 0000000000..f4bc99060a
--- /dev/null
+++ b/src/Prism.Core/Navigation/Regions/NavigationContextExtensions.cs
@@ -0,0 +1,23 @@
+using Prism.Common;
+
+namespace Prism.Navigation.Regions
+{
+ ///
+ /// Provides extensions for the Navigation Context
+ ///
+ public static class NavigationContextExtensions
+ {
+ ///
+ /// Gets the Navigation Segment name from the .
+ ///
+ /// The current instance of the .
+ /// The View Name that was navigated to.
+ public static string NavigatedName(this NavigationContext context)
+ {
+ var uri = UriParsingHelper.EnsureAbsolute(context.Uri);
+ var segments = UriParsingHelper.GetUriSegments(uri);
+ var segment = segments.Dequeue();
+ return UriParsingHelper.GetSegmentName(segment);
+ }
+ }
+}
diff --git a/src/Wpf/Prism.Wpf/Regions/RegionBehavior.cs b/src/Prism.Core/Navigation/Regions/RegionBehavior.cs
similarity index 97%
rename from src/Wpf/Prism.Wpf/Regions/RegionBehavior.cs
rename to src/Prism.Core/Navigation/Regions/RegionBehavior.cs
index 31da5a666a..8020d77ab3 100644
--- a/src/Wpf/Prism.Wpf/Regions/RegionBehavior.cs
+++ b/src/Prism.Core/Navigation/Regions/RegionBehavior.cs
@@ -1,9 +1,7 @@
-
-
using System;
using Prism.Properties;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Provides a base class for region's behaviors.
diff --git a/src/Wpf/Prism.Wpf/Regions/RegionBehaviorCollection.cs b/src/Prism.Core/Navigation/Regions/RegionBehaviorCollection.cs
similarity index 83%
rename from src/Wpf/Prism.Wpf/Regions/RegionBehaviorCollection.cs
rename to src/Prism.Core/Navigation/Regions/RegionBehaviorCollection.cs
index a31c9458e7..eb7889b667 100644
--- a/src/Wpf/Prism.Wpf/Regions/RegionBehaviorCollection.cs
+++ b/src/Prism.Core/Navigation/Regions/RegionBehaviorCollection.cs
@@ -1,10 +1,8 @@
-
-
using System;
using System.Collections;
using System.Collections.Generic;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// A collection of instances, that are stored and retrieved by Key.
@@ -27,10 +25,7 @@ public RegionBehaviorCollection(IRegion region)
/// Gets the with the specified key.
///
/// The RegionBehavior that's registered with the key.
- public IRegionBehavior this[string key]
- {
- get { return this.behaviors[key]; }
- }
+ public IRegionBehavior this[string key] => behaviors[key];
///
/// Adds a to the collection, using the specified key as an indexer.
@@ -50,11 +45,11 @@ public void Add(string key, IRegionBehavior regionBehavior)
if (regionBehavior == null)
throw new ArgumentNullException(nameof(regionBehavior));
- if (this.behaviors.ContainsKey(key))
+ if (behaviors.ContainsKey(key))
throw new ArgumentException("Could not add duplicate behavior with same key.", nameof(key));
- this.behaviors.Add(key, regionBehavior);
- regionBehavior.Region = this.region;
+ behaviors.Add(key, regionBehavior);
+ regionBehavior.Region = region;
regionBehavior.Attach();
}
@@ -64,10 +59,7 @@ public void Add(string key, IRegionBehavior regionBehavior)
///
/// The key to use to find a particular .
///
- public bool ContainsKey(string key)
- {
- return this.behaviors.ContainsKey(key);
- }
+ public bool ContainsKey(string key) => behaviors.ContainsKey(key);
///
/// Returns an enumerator that iterates through the collection.
@@ -75,10 +67,7 @@ public bool ContainsKey(string key)
///
/// A that can be used to iterate through the collection.
///
- public IEnumerator> GetEnumerator()
- {
- return behaviors.GetEnumerator();
- }
+ public IEnumerator> GetEnumerator() => behaviors.GetEnumerator();
///
/// Returns an enumerator that iterates through a collection.
@@ -86,9 +75,6 @@ public IEnumerator> GetEnumerator()
///
/// An object that can be used to iterate through the collection.
///
- IEnumerator IEnumerable.GetEnumerator()
- {
- return behaviors.GetEnumerator();
- }
+ IEnumerator IEnumerable.GetEnumerator() => behaviors.GetEnumerator();
}
}
diff --git a/src/Wpf/Prism.Wpf/Regions/RegionBehaviorFactory.cs b/src/Prism.Core/Navigation/Regions/RegionBehaviorFactory.cs
similarity index 95%
rename from src/Wpf/Prism.Wpf/Regions/RegionBehaviorFactory.cs
rename to src/Prism.Core/Navigation/Regions/RegionBehaviorFactory.cs
index 847e23a259..e0766d93ca 100644
--- a/src/Wpf/Prism.Wpf/Regions/RegionBehaviorFactory.cs
+++ b/src/Prism.Core/Navigation/Regions/RegionBehaviorFactory.cs
@@ -5,13 +5,12 @@
using Prism.Ioc;
using Prism.Properties;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Defines a factory that allows the registration of the default set of , that will
/// be added to the of all s, unless overridden on a 'per-region' basis.
///
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix", Justification = "It is more of a factory than a collection")]
public class RegionBehaviorFactory : IRegionBehaviorFactory
{
private readonly IContainerProvider _container;
diff --git a/src/Prism.Core/Navigation/Regions/RegionCreationException.cs b/src/Prism.Core/Navigation/Regions/RegionCreationException.cs
new file mode 100644
index 0000000000..6fd9cff532
--- /dev/null
+++ b/src/Prism.Core/Navigation/Regions/RegionCreationException.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+using System.Text;
+
+namespace Prism.Navigation.Regions;
+
+///
+/// An exception used when encountering an error in the creation of a Region
+///
+[Serializable]
+public sealed class RegionCreationException : RegionException
+{
+ ///
+ public RegionCreationException()
+ {
+ }
+
+ ///
+ public RegionCreationException(string message) : base(message)
+ {
+ }
+
+ ///
+ public RegionCreationException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ }
+
+ ///
+ public RegionCreationException(string message, Exception innerException) : base(message, innerException)
+ {
+ }
+}
diff --git a/src/Prism.Core/Navigation/Regions/RegionException.cs b/src/Prism.Core/Navigation/Regions/RegionException.cs
new file mode 100644
index 0000000000..85a56cf976
--- /dev/null
+++ b/src/Prism.Core/Navigation/Regions/RegionException.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Runtime.Serialization;
+
+namespace Prism.Navigation.Regions;
+
+///
+/// Provides a common base class for Region Exceptions
+///
+public abstract class RegionException : Exception
+{
+ ///
+ protected RegionException()
+ {
+ }
+
+ ///
+ protected RegionException(string message) : base(message)
+ {
+ }
+
+ ///
+ protected RegionException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ }
+
+ ///
+ protected RegionException(string message, Exception innerException) : base(message, innerException)
+ {
+ }
+}
diff --git a/src/Wpf/Prism.Wpf/Regions/RegionMemberLifetimeAttribute.cs b/src/Prism.Core/Navigation/Regions/RegionMemberLifetimeAttribute.cs
similarity index 83%
rename from src/Wpf/Prism.Wpf/Regions/RegionMemberLifetimeAttribute.cs
rename to src/Prism.Core/Navigation/Regions/RegionMemberLifetimeAttribute.cs
index d19544d624..7e2e6067e6 100644
--- a/src/Wpf/Prism.Wpf/Regions/RegionMemberLifetimeAttribute.cs
+++ b/src/Prism.Core/Navigation/Regions/RegionMemberLifetimeAttribute.cs
@@ -1,13 +1,10 @@
-
-
using System;
-using Prism.Regions.Behaviors;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// When is applied to class provides data
- /// the can use to determine if the instance should
+ /// the RegionMemberLifetimeBehavior can use to determine if the instance should
/// be removed when it is deactivated.
///
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true, Inherited = true)]
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Navigation/RegionNavigationEventArgs.cs b/src/Prism.Core/Navigation/Regions/RegionNavigationEventArgs.cs
similarity index 78%
rename from src/Forms/Prism.Forms.Regions/Regions/Navigation/RegionNavigationEventArgs.cs
rename to src/Prism.Core/Navigation/Regions/RegionNavigationEventArgs.cs
index 41754689e9..53b11a6ec9 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/Navigation/RegionNavigationEventArgs.cs
+++ b/src/Prism.Core/Navigation/Regions/RegionNavigationEventArgs.cs
@@ -1,6 +1,6 @@
-using System;
+using System;
-namespace Prism.Regions.Navigation
+namespace Prism.Navigation.Regions
{
///
/// EventArgs used with the Navigated event.
@@ -11,7 +11,7 @@ public class RegionNavigationEventArgs : EventArgs
/// Initializes a new instance of the class.
///
/// The navigation context.
- public RegionNavigationEventArgs(INavigationContext navigationContext)
+ public RegionNavigationEventArgs(NavigationContext navigationContext)
{
NavigationContext = navigationContext ?? throw new ArgumentNullException(nameof(navigationContext));
}
@@ -20,7 +20,7 @@ public RegionNavigationEventArgs(INavigationContext navigationContext)
/// Gets the navigation context.
///
/// The navigation context.
- public INavigationContext NavigationContext { get; }
+ public NavigationContext NavigationContext { get; }
///
/// Gets the navigation URI
@@ -29,6 +29,6 @@ public RegionNavigationEventArgs(INavigationContext navigationContext)
///
/// This is a convenience accessor around NavigationContext.Uri.
///
- public Uri Uri => NavigationContext?.Uri;
+ public Uri Uri => NavigationContext.Uri;
}
}
diff --git a/src/Forms/Prism.Forms.Regions/Regions/Navigation/RegionNavigationFailedEventArgs.cs b/src/Prism.Core/Navigation/Regions/RegionNavigationFailedEventArgs.cs
similarity index 80%
rename from src/Forms/Prism.Forms.Regions/Regions/Navigation/RegionNavigationFailedEventArgs.cs
rename to src/Prism.Core/Navigation/Regions/RegionNavigationFailedEventArgs.cs
index 09bfa25ae6..72f5c7188f 100644
--- a/src/Forms/Prism.Forms.Regions/Regions/Navigation/RegionNavigationFailedEventArgs.cs
+++ b/src/Prism.Core/Navigation/Regions/RegionNavigationFailedEventArgs.cs
@@ -1,6 +1,6 @@
-using System;
+using System;
-namespace Prism.Regions.Navigation
+namespace Prism.Navigation.Regions
{
///
/// EventArgs used with the NavigationFailed event.
@@ -11,7 +11,7 @@ public class RegionNavigationFailedEventArgs : EventArgs
/// Initializes a new instance of the class.
///
/// The navigation context.
- public RegionNavigationFailedEventArgs(INavigationContext navigationContext)
+ public RegionNavigationFailedEventArgs(NavigationContext navigationContext)
{
NavigationContext = navigationContext ?? throw new ArgumentNullException(nameof(navigationContext));
}
@@ -21,7 +21,7 @@ public RegionNavigationFailedEventArgs(INavigationContext navigationContext)
///
/// The navigation context.
/// The error.
- public RegionNavigationFailedEventArgs(INavigationContext navigationContext, Exception error)
+ public RegionNavigationFailedEventArgs(NavigationContext navigationContext, Exception error)
: this(navigationContext)
{
Error = error;
@@ -31,7 +31,7 @@ public RegionNavigationFailedEventArgs(INavigationContext navigationContext, Exc
/// Gets the navigation context.
///
/// The navigation context.
- public INavigationContext NavigationContext { get; }
+ public NavigationContext NavigationContext { get; }
///
/// Gets the error.
@@ -46,6 +46,6 @@ public RegionNavigationFailedEventArgs(INavigationContext navigationContext, Exc
///
/// This is a convenience accessor around NavigationContext.Uri.
///
- public Uri Uri => NavigationContext?.Uri;
+ public Uri Uri => NavigationContext.Uri;
}
}
diff --git a/src/Wpf/Prism.Wpf/Regions/RegionNavigationJournal.cs b/src/Prism.Core/Navigation/Regions/RegionNavigationJournal.cs
similarity index 94%
rename from src/Wpf/Prism.Wpf/Regions/RegionNavigationJournal.cs
rename to src/Prism.Core/Navigation/Regions/RegionNavigationJournal.cs
index 4d84963682..1ec8654fa3 100644
--- a/src/Wpf/Prism.Wpf/Regions/RegionNavigationJournal.cs
+++ b/src/Prism.Core/Navigation/Regions/RegionNavigationJournal.cs
@@ -1,12 +1,10 @@
-
-
using System;
using System.Collections.Generic;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
- /// Provides journaling of current, back, and forward navigation within regions.
+ /// Provides journaling of current, back, and forward navigation within regions.
///
public class RegionNavigationJournal : IRegionNavigationJournal
{
@@ -143,16 +141,16 @@ public void Clear()
private void InternalNavigate(IRegionNavigationJournalEntry entry, Action callback)
{
- this.isNavigatingInternal = true;
- this.NavigationTarget.RequestNavigate(
+ isNavigatingInternal = true;
+ NavigationTarget.RequestNavigate(
entry.Uri,
nr =>
{
- this.isNavigatingInternal = false;
+ isNavigatingInternal = false;
- if (nr.Result.HasValue)
+ if (nr.Success)
{
- callback(nr.Result.Value);
+ callback(nr.Success);
}
},
entry.Parameters);
diff --git a/src/Wpf/Prism.Wpf/Regions/RegionNavigationJournalEntry.cs b/src/Prism.Core/Navigation/Regions/RegionNavigationJournalEntry.cs
similarity index 96%
rename from src/Wpf/Prism.Wpf/Regions/RegionNavigationJournalEntry.cs
rename to src/Prism.Core/Navigation/Regions/RegionNavigationJournalEntry.cs
index 2c5427cd90..d9b7ec6dc5 100644
--- a/src/Wpf/Prism.Wpf/Regions/RegionNavigationJournalEntry.cs
+++ b/src/Prism.Core/Navigation/Regions/RegionNavigationJournalEntry.cs
@@ -2,7 +2,7 @@
using System.Globalization;
using Prism.Navigation;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// An entry in an IRegionNavigationJournal representing the URI navigated to.
diff --git a/src/Prism.Core/Navigation/Regions/RegionViewException.cs b/src/Prism.Core/Navigation/Regions/RegionViewException.cs
new file mode 100644
index 0000000000..fa865dd03f
--- /dev/null
+++ b/src/Prism.Core/Navigation/Regions/RegionViewException.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Runtime.Serialization;
+
+namespace Prism.Navigation.Regions;
+
+///
+/// An exception when there is an issue with a View being added to a Region
+///
+public sealed class RegionViewException : RegionException
+{
+ ///
+ /// Initializes a new
+ ///
+ public RegionViewException()
+ {
+ }
+
+ ///
+ /// Initializes a new
+ ///
+ /// The Exception Message.
+ public RegionViewException(string message) : base(message)
+ {
+ }
+
+ ///
+ public RegionViewException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ }
+
+ ///
+ /// Initializes a new
+ ///
+ /// The Exception Message.
+ /// The Inner .
+ public RegionViewException(string message, Exception innerException) : base(message, innerException)
+ {
+ }
+}
diff --git a/src/Prism.Core/Navigation/Regions/RegionViewRegistryExtensions.cs b/src/Prism.Core/Navigation/Regions/RegionViewRegistryExtensions.cs
new file mode 100644
index 0000000000..ec120af447
--- /dev/null
+++ b/src/Prism.Core/Navigation/Regions/RegionViewRegistryExtensions.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using Prism.Ioc;
+
+namespace Prism.Navigation.Regions
+{
+ ///
+ /// Provides extensions for the .
+ ///
+ public static class RegionViewRegistryExtensions
+ {
+ ///
+ /// Registers a delegate that can be used to retrieve the content associated with a region name.
+ ///
+ /// The instance.
+ /// Region name to which the will be registered.
+ /// Delegate used to retrieve the content associated with the .
+ public static void RegisterViewWithRegion(this IRegionViewRegistry viewRegistry, string regionName, Func getContentDelegate) =>
+ viewRegistry.RegisterViewWithRegion(regionName, _ => getContentDelegate());
+
+ ///
+ /// Returns the contents associated with a region name.
+ ///
+ /// The current instance.
+ /// Region name for which contents are requested.
+ /// Collection of contents associated with the .
+ public static IEnumerable GetContents(this IRegionViewRegistry viewRegistry, string regionName) =>
+ viewRegistry.GetContents(regionName, ContainerLocator.Container);
+ }
+}
diff --git a/src/Wpf/Prism.Wpf/Regions/SyncActiveStateAttribute.cs b/src/Prism.Core/Navigation/Regions/SyncActiveStateAttribute.cs
similarity index 88%
rename from src/Wpf/Prism.Wpf/Regions/SyncActiveStateAttribute.cs
rename to src/Prism.Core/Navigation/Regions/SyncActiveStateAttribute.cs
index 8b0d844159..0c8be40824 100644
--- a/src/Wpf/Prism.Wpf/Regions/SyncActiveStateAttribute.cs
+++ b/src/Prism.Core/Navigation/Regions/SyncActiveStateAttribute.cs
@@ -1,6 +1,6 @@
using System;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Defines that a view is synchronized with its parent view's Active state.
diff --git a/src/Wpf/Prism.Wpf/Regions/UpdateRegionsException.cs b/src/Prism.Core/Navigation/Regions/UpdateRegionsException.cs
similarity index 61%
rename from src/Wpf/Prism.Wpf/Regions/UpdateRegionsException.cs
rename to src/Prism.Core/Navigation/Regions/UpdateRegionsException.cs
index 267c451608..ca2c7dea0a 100644
--- a/src/Wpf/Prism.Wpf/Regions/UpdateRegionsException.cs
+++ b/src/Prism.Core/Navigation/Regions/UpdateRegionsException.cs
@@ -1,10 +1,12 @@
using System;
+using System.Runtime.Serialization;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
- /// Represents errors that occured during the regions' update.
+ /// Represents errors that occurred during the regions' update.
///
+ [Serializable]
public partial class UpdateRegionsException : Exception
{
///
@@ -24,15 +26,25 @@ public UpdateRegionsException(string message)
}
///
- /// Initializes a new instance of the class with a specified error message and a reference
- /// to the inner exception that is the cause of this exception.
+ /// Initializes a new instance of the class with a specified error message and a reference
+ /// to the inner exception that is the cause of this exception.
///
/// The error message that explains the reason for the exception.
- /// The exception that is the cause of the current exception, or a null reference
+ /// The exception that is the cause of the current exception, or a null reference
/// (Nothing in Visual Basic) if no inner exception is specified.
public UpdateRegionsException(string message, Exception inner)
: base(message, inner)
{
}
+
+ ///
+ /// Initializes a new instance of the class with serialized data.
+ ///
+ /// The that holds the serialized object data about the exception being thrown.
+ /// The that contains contextual information about the source or destination.
+ protected UpdateRegionsException(SerializationInfo info, StreamingContext context)
+ : base(info, context)
+ {
+ }
}
}
diff --git a/src/Wpf/Prism.Wpf/Regions/ViewRegisteredEventArgs.cs b/src/Prism.Core/Navigation/Regions/ViewRegisteredEventArgs.cs
similarity index 79%
rename from src/Wpf/Prism.Wpf/Regions/ViewRegisteredEventArgs.cs
rename to src/Prism.Core/Navigation/Regions/ViewRegisteredEventArgs.cs
index a2d71010e3..0fe3bd80de 100644
--- a/src/Wpf/Prism.Wpf/Regions/ViewRegisteredEventArgs.cs
+++ b/src/Prism.Core/Navigation/Regions/ViewRegisteredEventArgs.cs
@@ -1,8 +1,7 @@
-
-
using System;
+using Prism.Ioc;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Argument class used by the event when a new content is registered.
@@ -14,7 +13,7 @@ public class ViewRegisteredEventArgs : EventArgs
///
/// The region name to which the content was registered.
/// The content which was registered.
- public ViewRegisteredEventArgs(string regionName, Func getViewDelegate)
+ public ViewRegisteredEventArgs(string regionName, Func getViewDelegate)
{
this.GetView = getViewDelegate;
this.RegionName = regionName;
@@ -28,6 +27,6 @@ public ViewRegisteredEventArgs(string regionName, Func getViewDelegate)
///
/// Gets the content which was registered.
///
- public Func GetView { get; private set; }
+ public Func GetView { get; private set; }
}
}
diff --git a/src/Wpf/Prism.Wpf/Regions/ViewRegistrationException.cs b/src/Prism.Core/Navigation/Regions/ViewRegistrationException.cs
similarity index 68%
rename from src/Wpf/Prism.Wpf/Regions/ViewRegistrationException.cs
rename to src/Prism.Core/Navigation/Regions/ViewRegistrationException.cs
index a5b0784387..d5263342a8 100644
--- a/src/Wpf/Prism.Wpf/Regions/ViewRegistrationException.cs
+++ b/src/Prism.Core/Navigation/Regions/ViewRegistrationException.cs
@@ -1,10 +1,12 @@
using System;
+using System.Runtime.Serialization;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
- /// Exception that's thrown when something goes wrong while Registering a View with a region name in the class.
+ /// Exception that's thrown when something goes wrong while Registering a View with a region name in the class.
///
+ [Serializable]
public partial class ViewRegistrationException : Exception
{
// TODO: Find updated links as these are dead...
@@ -39,6 +41,15 @@ public ViewRegistrationException(string message, Exception inner) : base(message
{
}
-
+ ///
+ /// Initializes a new instance of the class with serialized data.
+ ///
+ /// The that holds the serialized
+ /// object data about the exception being thrown.
+ /// The that contains contextual information about the source or destination.
+ protected ViewRegistrationException(SerializationInfo info, StreamingContext context)
+ : base(info, context)
+ {
+ }
}
}
diff --git a/src/Wpf/Prism.Wpf/Regions/ViewSortHintAttribute.cs b/src/Prism.Core/Navigation/Regions/ViewSortHintAttribute.cs
similarity index 95%
rename from src/Wpf/Prism.Wpf/Regions/ViewSortHintAttribute.cs
rename to src/Prism.Core/Navigation/Regions/ViewSortHintAttribute.cs
index d619af282f..6559a0eedf 100644
--- a/src/Wpf/Prism.Wpf/Regions/ViewSortHintAttribute.cs
+++ b/src/Prism.Core/Navigation/Regions/ViewSortHintAttribute.cs
@@ -1,7 +1,7 @@
using System;
using System.Net;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Provides a hint from a view to a region on how to sort the view.
diff --git a/src/Prism.Core/Properties/Resources.Designer.cs b/src/Prism.Core/Properties/Resources.Designer.cs
index 73c1c2683b..9746ad9e3f 100644
--- a/src/Prism.Core/Properties/Resources.Designer.cs
+++ b/src/Prism.Core/Properties/Resources.Designer.cs
@@ -78,6 +78,15 @@ internal static string CannotRegisterSameCommandTwice {
}
}
+ ///
+ /// Looks up a localized string similar to Type '{0}' does not implement from IRegionBehavior..
+ ///
+ internal static string CanOnlyAddTypesThatInheritIFromRegionBehavior {
+ get {
+ return ResourceManager.GetString("CanOnlyAddTypesThatInheritIFromRegionBehavior", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to At least one cyclic dependency has been found in the module catalog. Cycles in the module dependencies must be avoided..
///
@@ -221,6 +230,24 @@ internal static string PropertySupport_StaticExpression_Exception {
}
}
+ ///
+ /// Looks up a localized string similar to The Attach method cannot be called when Region property is null..
+ ///
+ internal static string RegionBehaviorAttachCannotBeCallWithNullRegion {
+ get {
+ return ResourceManager.GetString("RegionBehaviorAttachCannotBeCallWithNullRegion", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to The Region property cannot be set after Attach method has been called..
+ ///
+ internal static string RegionBehaviorRegionCannotBeSetAfterAttach {
+ get {
+ return ResourceManager.GetString("RegionBehaviorRegionCannotBeSetAfterAttach", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Module {0} is marked for automatic initialization when the application starts, but it depends on modules that are marked as OnDemand initialization. To fix this error, mark the dependency modules for InitializationMode=WhenAvailable, or remove this validation by extending the ModuleCatalog class..
///
@@ -238,5 +265,14 @@ internal static string StringCannotBeNullOrEmpty {
return ResourceManager.GetString("StringCannotBeNullOrEmpty", resourceCulture);
}
}
+
+ ///
+ /// Looks up a localized string similar to No BehaviorType with key '{0}' was registered..
+ ///
+ internal static string TypeWithKeyNotRegistered {
+ get {
+ return ResourceManager.GetString("TypeWithKeyNotRegistered", resourceCulture);
+ }
+ }
}
}
diff --git a/src/Prism.Core/Properties/Resources.resx b/src/Prism.Core/Properties/Resources.resx
index 13680eed5a..fef38b6bab 100644
--- a/src/Prism.Core/Properties/Resources.resx
+++ b/src/Prism.Core/Properties/Resources.resx
@@ -123,6 +123,9 @@
Cannot register the same command twice in the same CompositeCommand.
+
+ Type '{0}' does not implement from IRegionBehavior.
+
At least one cyclic dependency has been found in the module catalog. Cycles in the module dependencies must be avoided.
@@ -176,10 +179,19 @@ Error was: {1}.
The referenced property is a static property.
+
+ The Attach method cannot be called when Region property is null.
+
+
+ The Region property cannot be set after Attach method has been called.
+
Module {0} is marked for automatic initialization when the application starts, but it depends on modules that are marked as OnDemand initialization. To fix this error, mark the dependency modules for InitializationMode=WhenAvailable, or remove this validation by extending the ModuleCatalog class.The provided String argument {0} must not be null or empty.
+
+ No BehaviorType with key '{0}' was registered.
+
\ No newline at end of file
diff --git a/src/Uno/Prism.Uno/build/Prism.Uno.WinUI.targets b/src/Prism.Core/build/Package.targets
similarity index 80%
rename from src/Uno/Prism.Uno/build/Prism.Uno.WinUI.targets
rename to src/Prism.Core/build/Package.targets
index c600067cdd..84a626eca2 100644
--- a/src/Uno/Prism.Uno/build/Prism.Uno.WinUI.targets
+++ b/src/Prism.Core/build/Package.targets
@@ -1,13 +1,14 @@
-
+
+
+
-
+
-
-
+
diff --git a/src/Uno/Prism.DryIoc.Uno/build/Prism.DryIoc.Uno.targets b/src/Uno/Prism.DryIoc.Uno/build/Package.targets
similarity index 100%
rename from src/Uno/Prism.DryIoc.Uno/build/Prism.DryIoc.Uno.targets
rename to src/Uno/Prism.DryIoc.Uno/build/Package.targets
diff --git a/src/Uno/Prism.Uno/Prism.Uno.WinUI.csproj b/src/Uno/Prism.Uno/Prism.Uno.WinUI.csproj
index 665ba1ac20..dffe8ac177 100644
--- a/src/Uno/Prism.Uno/Prism.Uno.WinUI.csproj
+++ b/src/Uno/Prism.Uno/Prism.Uno.WinUI.csproj
@@ -21,7 +21,6 @@
-
diff --git a/src/Uno/Prism.Uno/PrismApplicationBase.cs b/src/Uno/Prism.Uno/PrismApplicationBase.cs
index 7fe5cbac06..4160a15611 100644
--- a/src/Uno/Prism.Uno/PrismApplicationBase.cs
+++ b/src/Uno/Prism.Uno/PrismApplicationBase.cs
@@ -5,8 +5,7 @@
using Prism.Ioc;
using Prism.Modularity;
using Prism.Mvvm;
-using Prism.Regions;
-using Uno.Extensions.Hosting;
+using Prism.Navigation.Regions;
using Application = Microsoft.UI.Xaml.Application;
#nullable enable
@@ -132,8 +131,8 @@ protected virtual void Initialize(IApplicationBuilder builder)
void FinalizeInitialization()
{
- Regions.RegionManager.SetRegionManager(shell, _containerExtension.Resolve());
- Regions.RegionManager.UpdateRegions();
+ Navigation.Regions.RegionManager.SetRegionManager(shell, _containerExtension.Resolve());
+ Navigation.Regions.RegionManager.UpdateRegions();
_host = builder.Build();
InitializeModules();
OnInitialized();
diff --git a/src/Wpf/Prism.DryIoc.Wpf/PrismApplication.cs b/src/Wpf/Prism.DryIoc.Wpf/PrismApplication.cs
index 56c41fe3f6..42d2d911a5 100644
--- a/src/Wpf/Prism.DryIoc.Wpf/PrismApplication.cs
+++ b/src/Wpf/Prism.DryIoc.Wpf/PrismApplication.cs
@@ -1,7 +1,7 @@
using System;
using DryIoc;
using Prism.Ioc;
-using Prism.Regions;
+using Prism.Navigation.Regions;
using ExceptionExtensions = System.ExceptionExtensions;
namespace Prism.DryIoc
@@ -27,7 +27,7 @@ protected override IContainerExtension CreateContainerExtension()
}
///
- /// Registers the s of the Exceptions that are not considered
+ /// Registers the s of the Exceptions that are not considered
/// root exceptions by the .
///
protected override void RegisterFrameworkExceptionTypes()
diff --git a/src/Wpf/Prism.Wpf/Regions/AllActiveRegion.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/AllActiveRegion.cs
similarity index 96%
rename from src/Wpf/Prism.Wpf/Regions/AllActiveRegion.cs
rename to src/Wpf/Prism.Wpf/Navigation/Regions/AllActiveRegion.cs
index 6216a7afe3..92441b20e2 100644
--- a/src/Wpf/Prism.Wpf/Regions/AllActiveRegion.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/AllActiveRegion.cs
@@ -1,7 +1,7 @@
using System;
using Prism.Properties;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Region that keeps all the views in it as active. Deactivation of views is not allowed.
diff --git a/src/Wpf/Prism.Wpf/Regions/Behaviors/AutoPopulateRegionBehavior.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/AutoPopulateRegionBehavior.cs
similarity index 96%
rename from src/Wpf/Prism.Wpf/Regions/Behaviors/AutoPopulateRegionBehavior.cs
rename to src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/AutoPopulateRegionBehavior.cs
index f323633921..a8accd4eaa 100644
--- a/src/Wpf/Prism.Wpf/Regions/Behaviors/AutoPopulateRegionBehavior.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/AutoPopulateRegionBehavior.cs
@@ -1,7 +1,8 @@
using System;
using System.Collections.Generic;
+using Prism.Ioc;
-namespace Prism.Regions.Behaviors
+namespace Prism.Navigation.Regions.Behaviors
{
///
/// Populates the target region with the views registered to it in the .
@@ -92,7 +93,7 @@ public virtual void OnViewRegistered(object sender, ViewRegisteredEventArgs e)
if (e.RegionName == this.Region.Name)
{
- AddViewIntoRegion(e.GetView());
+ AddViewIntoRegion(e.GetView(ContainerLocator.Container));
}
}
}
diff --git a/src/Wpf/Prism.Wpf/Regions/Behaviors/BindRegionContextToDependencyObjectBehavior.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/BindRegionContextToDependencyObjectBehavior.cs
similarity index 98%
rename from src/Wpf/Prism.Wpf/Regions/Behaviors/BindRegionContextToDependencyObjectBehavior.cs
rename to src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/BindRegionContextToDependencyObjectBehavior.cs
index 79abbd3d6f..a90ddde8fb 100644
--- a/src/Wpf/Prism.Wpf/Regions/Behaviors/BindRegionContextToDependencyObjectBehavior.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/BindRegionContextToDependencyObjectBehavior.cs
@@ -1,5 +1,3 @@
-
-
using Prism.Common;
using System.Collections;
using System.Collections.Specialized;
@@ -11,7 +9,7 @@
using System.Windows;
#endif
-namespace Prism.Regions.Behaviors
+namespace Prism.Navigation.Regions.Behaviors
{
///
/// Defines a behavior that forwards the
diff --git a/src/Wpf/Prism.Wpf/Regions/Behaviors/ClearChildViewsRegionBehavior.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/ClearChildViewsRegionBehavior.cs
similarity index 98%
rename from src/Wpf/Prism.Wpf/Regions/Behaviors/ClearChildViewsRegionBehavior.cs
rename to src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/ClearChildViewsRegionBehavior.cs
index 286e014bcc..040a4701d2 100644
--- a/src/Wpf/Prism.Wpf/Regions/Behaviors/ClearChildViewsRegionBehavior.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/ClearChildViewsRegionBehavior.cs
@@ -1,5 +1,3 @@
-
-
using System;
#if HAS_WINUI
@@ -8,7 +6,7 @@
using System.Windows;
#endif
-namespace Prism.Regions.Behaviors
+namespace Prism.Navigation.Regions.Behaviors
{
///
/// Behavior that removes the RegionManager attached property of all the views in a region once the RegionManager property of a region becomes null.
diff --git a/src/Wpf/Prism.Wpf/Regions/Behaviors/DelayedRegionCreationBehavior.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/DelayedRegionCreationBehavior.cs
similarity index 99%
rename from src/Wpf/Prism.Wpf/Regions/Behaviors/DelayedRegionCreationBehavior.cs
rename to src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/DelayedRegionCreationBehavior.cs
index a703c60d87..994fbc4d0e 100644
--- a/src/Wpf/Prism.Wpf/Regions/Behaviors/DelayedRegionCreationBehavior.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/DelayedRegionCreationBehavior.cs
@@ -10,7 +10,7 @@
using System.Windows;
#endif
-namespace Prism.Regions.Behaviors
+namespace Prism.Navigation.Regions.Behaviors
{
///
/// Behavior that creates a new , when the control that will host the (see )
diff --git a/src/Wpf/Prism.Wpf/Regions/Behaviors/DestructibleRegionBehavior.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/DestructibleRegionBehavior.cs
similarity index 95%
rename from src/Wpf/Prism.Wpf/Regions/Behaviors/DestructibleRegionBehavior.cs
rename to src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/DestructibleRegionBehavior.cs
index eedfeee515..47252c3610 100644
--- a/src/Wpf/Prism.Wpf/Regions/Behaviors/DestructibleRegionBehavior.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/DestructibleRegionBehavior.cs
@@ -1,9 +1,8 @@
using System;
using System.Collections.Specialized;
using Prism.Common;
-using Prism.Navigation;
-namespace Prism.Regions.Behaviors
+namespace Prism.Navigation.Regions.Behaviors
{
///
/// Calls on Views and ViewModels
diff --git a/src/Wpf/Prism.Wpf/Regions/Behaviors/IHostAwareRegionBehavior.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/IHostAwareRegionBehavior.cs
similarity index 94%
rename from src/Wpf/Prism.Wpf/Regions/Behaviors/IHostAwareRegionBehavior.cs
rename to src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/IHostAwareRegionBehavior.cs
index 20f2b5162f..ee303ac768 100644
--- a/src/Wpf/Prism.Wpf/Regions/Behaviors/IHostAwareRegionBehavior.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/IHostAwareRegionBehavior.cs
@@ -1,12 +1,10 @@
-
-
#if HAS_WINUI
using Microsoft.UI.Xaml;
#else
using System.Windows;
#endif
-namespace Prism.Regions.Behaviors
+namespace Prism.Navigation.Regions.Behaviors
{
///
/// Defines a that not allows extensible behaviors on regions which also interact
diff --git a/src/Wpf/Prism.Wpf/Regions/Behaviors/RegionActiveAwareBehavior.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/RegionActiveAwareBehavior.cs
similarity index 95%
rename from src/Wpf/Prism.Wpf/Regions/Behaviors/RegionActiveAwareBehavior.cs
rename to src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/RegionActiveAwareBehavior.cs
index 0783187bb7..dc9866dab9 100644
--- a/src/Wpf/Prism.Wpf/Regions/Behaviors/RegionActiveAwareBehavior.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/RegionActiveAwareBehavior.cs
@@ -1,9 +1,6 @@
-
-
using System;
using System.Collections.Specialized;
using System.Linq;
-using System.Reflection;
using Prism.Common;
#if HAS_WINUI
@@ -12,7 +9,7 @@
using System.Windows;
#endif
-namespace Prism.Regions.Behaviors
+namespace Prism.Navigation.Regions.Behaviors
{
///
/// Behavior that monitors a object and
@@ -22,7 +19,7 @@ namespace Prism.Regions.Behaviors
///
///
/// This class can also sync the active state for any scoped regions directly on the view based on the .
- /// If you use the method with the createRegionManagerScope option, the scoped manager will be attached to the view.
+ /// If you use the method with the createRegionManagerScope option, the scoped manager will be attached to the view.
///
public class RegionActiveAwareBehavior : IRegionBehavior
{
diff --git a/src/Wpf/Prism.Wpf/Regions/Behaviors/RegionManagerRegistrationBehavior.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/RegionManagerRegistrationBehavior.cs
similarity index 98%
rename from src/Wpf/Prism.Wpf/Regions/Behaviors/RegionManagerRegistrationBehavior.cs
rename to src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/RegionManagerRegistrationBehavior.cs
index 68521b4752..0f42de884a 100644
--- a/src/Wpf/Prism.Wpf/Regions/Behaviors/RegionManagerRegistrationBehavior.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/RegionManagerRegistrationBehavior.cs
@@ -1,9 +1,6 @@
-
-
using System;
using System.ComponentModel;
using Prism.Properties;
-using System.Globalization;
#if HAS_WINUI
using Microsoft.UI.Xaml;
@@ -12,7 +9,7 @@
using System.Windows;
#endif
-namespace Prism.Regions.Behaviors
+namespace Prism.Navigation.Regions.Behaviors
{
///
/// Subscribes to a static event from the in order to register the target
diff --git a/src/Wpf/Prism.Wpf/Regions/Behaviors/RegionMemberLifetimeBehavior.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/RegionMemberLifetimeBehavior.cs
similarity index 99%
rename from src/Wpf/Prism.Wpf/Regions/Behaviors/RegionMemberLifetimeBehavior.cs
rename to src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/RegionMemberLifetimeBehavior.cs
index 5fead2a529..3047a22e3b 100644
--- a/src/Wpf/Prism.Wpf/Regions/Behaviors/RegionMemberLifetimeBehavior.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/RegionMemberLifetimeBehavior.cs
@@ -1,5 +1,3 @@
-
-
using System;
using System.Collections.Generic;
using System.Linq;
@@ -12,7 +10,7 @@
using System.Windows;
#endif
-namespace Prism.Regions.Behaviors
+namespace Prism.Navigation.Regions.Behaviors
{
///
/// The RegionMemberLifetimeBehavior determines if items should be removed from the
diff --git a/src/Wpf/Prism.Wpf/Regions/Behaviors/SelectorItemsSourceSyncBehavior.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/SelectorItemsSourceSyncBehavior.cs
similarity index 99%
rename from src/Wpf/Prism.Wpf/Regions/Behaviors/SelectorItemsSourceSyncBehavior.cs
rename to src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/SelectorItemsSourceSyncBehavior.cs
index 72ea6e59b9..9654e5bf68 100644
--- a/src/Wpf/Prism.Wpf/Regions/Behaviors/SelectorItemsSourceSyncBehavior.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/SelectorItemsSourceSyncBehavior.cs
@@ -1,5 +1,3 @@
-
-
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
@@ -17,7 +15,7 @@
using System.Windows.Data;
#endif
-namespace Prism.Regions.Behaviors
+namespace Prism.Navigation.Regions.Behaviors
{
///
/// Defines the attached behavior that keeps the items of the host control in synchronization with the .
diff --git a/src/Wpf/Prism.Wpf/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs
similarity index 98%
rename from src/Wpf/Prism.Wpf/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs
rename to src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs
index da70aa8bcb..e545d5cfa3 100644
--- a/src/Wpf/Prism.Wpf/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/SyncRegionContextWithHostBehavior.cs
@@ -1,5 +1,3 @@
-
-
using System;
using Prism.Properties;
using Prism.Common;
@@ -10,7 +8,7 @@
using System.Windows;
#endif
-namespace Prism.Regions.Behaviors
+namespace Prism.Navigation.Regions.Behaviors
{
///
/// Behavior that synchronizes the property of a with
diff --git a/src/Wpf/Prism.Wpf/Regions/ContentControlRegionAdapter.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/ContentControlRegionAdapter.cs
similarity index 98%
rename from src/Wpf/Prism.Wpf/Regions/ContentControlRegionAdapter.cs
rename to src/Wpf/Prism.Wpf/Navigation/Regions/ContentControlRegionAdapter.cs
index 4be4e8166f..02d928ad6e 100644
--- a/src/Wpf/Prism.Wpf/Regions/ContentControlRegionAdapter.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/ContentControlRegionAdapter.cs
@@ -1,5 +1,3 @@
-
-
using Prism.Properties;
using System;
using System.Collections.Specialized;
@@ -14,7 +12,7 @@
using System.Windows.Data;
#endif
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Adapter that creates a new and monitors its
diff --git a/src/Wpf/Prism.Wpf/Regions/DefaultRegionManagerAccessor.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/DefaultRegionManagerAccessor.cs
similarity index 98%
rename from src/Wpf/Prism.Wpf/Regions/DefaultRegionManagerAccessor.cs
rename to src/Wpf/Prism.Wpf/Navigation/Regions/DefaultRegionManagerAccessor.cs
index 79fa1fae0f..cf08bff621 100644
--- a/src/Wpf/Prism.Wpf/Regions/DefaultRegionManagerAccessor.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/DefaultRegionManagerAccessor.cs
@@ -6,7 +6,7 @@
using System.Windows;
#endif
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
internal class DefaultRegionManagerAccessor : IRegionManagerAccessor
{
diff --git a/src/Wpf/Prism.Wpf/Navigation/Regions/INavigationAware.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/INavigationAware.cs
new file mode 100644
index 0000000000..d43cc12808
--- /dev/null
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/INavigationAware.cs
@@ -0,0 +1,15 @@
+#if !HAS_UNO_WINUI && !HAS_WINUI
+
+namespace Prism.Navigation.Regions
+{
+ ///
+ /// Provides a way for objects involved in navigation to be notified of navigation activities.
+ ///
+ ///
+ /// Provides compatibility for Legacy Prism.Wpf apps.
+ ///
+ public interface INavigationAware : IRegionAware
+ {
+ }
+}
+#endif
diff --git a/src/Wpf/Prism.Wpf/Regions/IRegionManagerAccessor.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/IRegionManagerAccessor.cs
similarity index 97%
rename from src/Wpf/Prism.Wpf/Regions/IRegionManagerAccessor.cs
rename to src/Wpf/Prism.Wpf/Navigation/Regions/IRegionManagerAccessor.cs
index fff02c4805..185e30bed2 100644
--- a/src/Wpf/Prism.Wpf/Regions/IRegionManagerAccessor.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/IRegionManagerAccessor.cs
@@ -1,5 +1,3 @@
-
-
using System;
#if HAS_WINUI
@@ -8,7 +6,7 @@
using System.Windows;
#endif
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Provides an abstraction on top of the RegionManager static members.
diff --git a/src/Wpf/Prism.Wpf/Regions/ItemMetadata.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/ItemMetadata.cs
similarity index 81%
rename from src/Wpf/Prism.Wpf/Regions/ItemMetadata.cs
rename to src/Wpf/Prism.Wpf/Navigation/Regions/ItemMetadata.cs
index ec02a6ec46..721149db72 100644
--- a/src/Wpf/Prism.Wpf/Regions/ItemMetadata.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/ItemMetadata.cs
@@ -1,5 +1,3 @@
-
-
using System;
#if HAS_WINUI
@@ -8,7 +6,7 @@
using System.Windows;
#endif
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Defines a class that wraps an item and adds metadata for it.
@@ -19,13 +17,13 @@ public partial class ItemMetadata : DependencyObject
/// The name of the wrapped item.
///
public static readonly DependencyProperty NameProperty =
- DependencyProperty.Register("Name", typeof(string), typeof(ItemMetadata), null);
+ DependencyProperty.Register(nameof(Name), typeof(string), typeof(ItemMetadata), null);
///
/// Value indicating whether the wrapped item is considered active.
///
public static readonly DependencyProperty IsActiveProperty =
- DependencyProperty.Register("IsActive", typeof(bool), typeof(ItemMetadata), new PropertyMetadata(defaultValue: false, propertyChangedCallback: DependencyPropertyChanged));
+ DependencyProperty.Register(nameof(IsActive), typeof(bool), typeof(ItemMetadata), new PropertyMetadata(defaultValue: false, propertyChangedCallback: DependencyPropertyChanged));
///
/// Initializes a new instance of .
@@ -34,7 +32,7 @@ public partial class ItemMetadata : DependencyObject
public ItemMetadata(object item)
{
// check for null
- this.Item = item;
+ Item = item;
}
///
@@ -49,8 +47,8 @@ public ItemMetadata(object item)
/// The name of the wrapped item.
public string Name
{
- get { return (string)GetValue(NameProperty); }
- set { SetValue(NameProperty, value); }
+ get => (string)GetValue(NameProperty);
+ set => SetValue(NameProperty, value);
}
///
@@ -59,8 +57,8 @@ public string Name
/// if the item should be considered active; otherwise .
public bool IsActive
{
- get { return (bool)GetValue(IsActiveProperty); }
- set { SetValue(IsActiveProperty, value); }
+ get => (bool)GetValue(IsActiveProperty);
+ set => SetValue(IsActiveProperty, value);
}
///
diff --git a/src/Wpf/Prism.Wpf/Regions/ItemsControlRegionAdapter.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/ItemsControlRegionAdapter.cs
similarity index 98%
rename from src/Wpf/Prism.Wpf/Regions/ItemsControlRegionAdapter.cs
rename to src/Wpf/Prism.Wpf/Navigation/Regions/ItemsControlRegionAdapter.cs
index 5b10db0092..b7c08a32d8 100644
--- a/src/Wpf/Prism.Wpf/Regions/ItemsControlRegionAdapter.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/ItemsControlRegionAdapter.cs
@@ -1,5 +1,3 @@
-
-
using Prism.Properties;
using System;
@@ -13,7 +11,7 @@
using System.Windows.Data;
#endif
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Adapter that creates a new and binds all
diff --git a/src/Wpf/Prism.Wpf/Regions/Region.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/Region.cs
similarity index 89%
rename from src/Wpf/Prism.Wpf/Regions/Region.cs
rename to src/Wpf/Prism.Wpf/Navigation/Regions/Region.cs
index ce84324750..fea6bd0e6a 100644
--- a/src/Wpf/Prism.Wpf/Regions/Region.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/Region.cs
@@ -1,12 +1,10 @@
using System;
using System.Collections.ObjectModel;
-using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using Prism.Properties;
using Prism.Ioc;
-using Prism.Navigation;
#if HAS_WINUI
using Microsoft.UI.Xaml;
@@ -18,7 +16,7 @@
using System.Windows.Data;
#endif
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Implementation of that allows multiple active views.
@@ -32,6 +30,7 @@ public class Region : IRegion
private object _context;
private IRegionManager _regionManager;
private IRegionNavigationService _regionNavigationService;
+ private IContainerProvider _container;
private Comparison _sort;
@@ -41,6 +40,7 @@ public class Region : IRegion
public Region()
{
Behaviors = new RegionBehaviorCollection(this);
+ _container = ContainerLocator.Container;
_sort = DefaultSortComparison;
}
@@ -226,6 +226,18 @@ protected virtual ObservableCollection ItemMetadataCollection
}
}
+ /// Adds a new view to the region.
+ ///
+ /// Adds a new view to the region.
+ ///
+ /// The view to add.
+ /// The that is set on the view if it is a . It will be the current region manager when using this overload.
+ public IRegionManager Add(string viewName)
+ {
+ var view = _container.Resolve(viewName);
+ return Add(view, viewName, false);
+ }
+
/// Adds a new view to the region.
///
/// Adds a new view to the region.
@@ -234,7 +246,7 @@ protected virtual ObservableCollection ItemMetadataCollection
/// The that is set on the view if it is a . It will be the current region manager when using this overload.
public IRegionManager Add(object view)
{
- return this.Add(view, null, false);
+ return Add(view, null, false);
}
///
@@ -250,7 +262,7 @@ public IRegionManager Add(object view, string viewName)
throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.StringCannotBeNullOrEmpty, "viewName"));
}
- return this.Add(view, viewName, false);
+ return Add(view, viewName, false);
}
///
@@ -262,8 +274,8 @@ public IRegionManager Add(object view, string viewName)
/// The that is set on the view if it is a .
public virtual IRegionManager Add(object view, string viewName, bool createRegionManagerScope)
{
- IRegionManager manager = createRegionManagerScope ? this.RegionManager.CreateRegionManager() : this.RegionManager;
- this.InnerAdd(view, viewName, manager);
+ IRegionManager manager = createRegionManagerScope ? RegionManager.CreateRegionManager() : RegionManager;
+ InnerAdd(view, viewName, manager);
return manager;
}
@@ -273,11 +285,11 @@ public virtual IRegionManager Add(object view, string viewName, bool createRegio
/// The view to remove.
public virtual void Remove(object view)
{
- ItemMetadata itemMetadata = this.GetItemMetadataOrThrow(view);
+ ItemMetadata itemMetadata = GetItemMetadataOrThrow(view);
ItemMetadataCollection.Remove(itemMetadata);
- if (view is DependencyObject dependencyObject && Regions.RegionManager.GetRegionManager(dependencyObject) == this.RegionManager)
+ if (view is DependencyObject dependencyObject && Regions.RegionManager.GetRegionManager(dependencyObject) == RegionManager)
{
dependencyObject.ClearValue(Regions.RegionManager.RegionManagerProperty);
}
@@ -300,7 +312,7 @@ public void RemoveAll()
/// The view to activate.
public virtual void Activate(object view)
{
- ItemMetadata itemMetadata = this.GetItemMetadataOrThrow(view);
+ ItemMetadata itemMetadata = GetItemMetadataOrThrow(view);
if (!itemMetadata.IsActive)
{
@@ -314,7 +326,7 @@ public virtual void Activate(object view)
/// The view to deactivate.
public virtual void Deactivate(object view)
{
- ItemMetadata itemMetadata = this.GetItemMetadataOrThrow(view);
+ ItemMetadata itemMetadata = GetItemMetadataOrThrow(view);
if (itemMetadata.IsActive)
{
@@ -334,7 +346,7 @@ public virtual object GetView(string viewName)
throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.StringCannotBeNullOrEmpty, "viewName"));
}
- ItemMetadata metadata = this.ItemMetadataCollection.FirstOrDefault(x => x.Name == viewName);
+ ItemMetadata metadata = ItemMetadataCollection.FirstOrDefault(x => x.Name == viewName);
if (metadata != null)
{
@@ -351,7 +363,7 @@ public virtual object GetView(string viewName)
/// A callback to execute when the navigation request is completed.
public void RequestNavigate(Uri target, Action navigationCallback)
{
- this.RequestNavigate(target, navigationCallback, null);
+ RequestNavigate(target, navigationCallback, null);
}
///
@@ -362,22 +374,22 @@ public void RequestNavigate(Uri target, Action navigationCallb
/// The navigation parameters specific to the navigation request.
public void RequestNavigate(Uri target, Action navigationCallback, INavigationParameters navigationParameters)
{
- this.NavigationService.RequestNavigate(target, navigationCallback, navigationParameters);
+ NavigationService.RequestNavigate(target, navigationCallback, navigationParameters);
}
private void InnerAdd(object view, string viewName, IRegionManager scopedRegionManager)
{
- if (this.ItemMetadataCollection.FirstOrDefault(x => x.Item == view) != null)
+ if (ItemMetadataCollection.FirstOrDefault(x => x.Item == view) != null)
{
throw new InvalidOperationException(Resources.RegionViewExistsException);
}
- ItemMetadata itemMetadata = new ItemMetadata(view);
+ var itemMetadata = new ItemMetadata(view);
if (!string.IsNullOrEmpty(viewName))
{
- if (this.ItemMetadataCollection.FirstOrDefault(x => x.Name == viewName) != null)
+ if (ItemMetadataCollection.FirstOrDefault(x => x.Name == viewName) != null)
{
- throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, Resources.RegionViewNameExistsException, viewName));
+ throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, Resources.RegionViewNameExistsException, viewName));
}
itemMetadata.Name = viewName;
}
@@ -388,7 +400,7 @@ private void InnerAdd(object view, string viewName, IRegionManager scopedRegionM
Regions.RegionManager.SetRegionManager(dependencyObject, scopedRegionManager);
}
- this.ItemMetadataCollection.Add(itemMetadata);
+ ItemMetadataCollection.Add(itemMetadata);
}
private ItemMetadata GetItemMetadataOrThrow(object view)
@@ -396,7 +408,7 @@ private ItemMetadata GetItemMetadataOrThrow(object view)
if (view == null)
throw new ArgumentNullException(nameof(view));
- ItemMetadata itemMetadata = this.ItemMetadataCollection.FirstOrDefault(x => x.Item == view);
+ ItemMetadata itemMetadata = ItemMetadataCollection.FirstOrDefault(x => x.Item == view);
if (itemMetadata == null)
throw new ArgumentException(Resources.ViewNotInRegionException, nameof(view));
diff --git a/src/Wpf/Prism.Wpf/Regions/RegionAdapterBase.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/RegionAdapterBase.cs
similarity index 98%
rename from src/Wpf/Prism.Wpf/Regions/RegionAdapterBase.cs
rename to src/Wpf/Prism.Wpf/Navigation/Regions/RegionAdapterBase.cs
index 38b484837c..588c6755dc 100644
--- a/src/Wpf/Prism.Wpf/Regions/RegionAdapterBase.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/RegionAdapterBase.cs
@@ -1,7 +1,5 @@
-
-
using Prism.Properties;
-using Prism.Regions.Behaviors;
+using Prism.Navigation.Regions.Behaviors;
using System;
using System.Globalization;
@@ -12,7 +10,7 @@
using System.Windows;
#endif
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Base class to facilitate the creation of implementations.
diff --git a/src/Wpf/Prism.Wpf/Regions/RegionAdapterMappings.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/RegionAdapterMappings.cs
similarity index 99%
rename from src/Wpf/Prism.Wpf/Regions/RegionAdapterMappings.cs
rename to src/Wpf/Prism.Wpf/Navigation/Regions/RegionAdapterMappings.cs
index 42c3a9f7e7..d42f48fb29 100644
--- a/src/Wpf/Prism.Wpf/Regions/RegionAdapterMappings.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/RegionAdapterMappings.cs
@@ -4,7 +4,7 @@
using Prism.Ioc;
using Prism.Properties;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// This class maps with .
diff --git a/src/Wpf/Prism.Wpf/Regions/RegionContext.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/RegionContext.cs
similarity index 98%
rename from src/Wpf/Prism.Wpf/Regions/RegionContext.cs
rename to src/Wpf/Prism.Wpf/Navigation/Regions/RegionContext.cs
index 1154d83a08..48d61b405e 100644
--- a/src/Wpf/Prism.Wpf/Regions/RegionContext.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/RegionContext.cs
@@ -1,5 +1,3 @@
-
-
using Prism.Common;
using System;
@@ -9,7 +7,7 @@
using System.Windows;
#endif
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Class that holds methods to Set and Get the RegionContext from a DependencyObject.
diff --git a/src/Wpf/Prism.Wpf/Regions/RegionManager.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/RegionManager.cs
similarity index 84%
rename from src/Wpf/Prism.Wpf/Regions/RegionManager.cs
rename to src/Wpf/Prism.Wpf/Navigation/Regions/RegionManager.cs
index 50c6829019..3b2e7b7b94 100644
--- a/src/Wpf/Prism.Wpf/Regions/RegionManager.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/RegionManager.cs
@@ -11,9 +11,8 @@
using Prism.Events;
using Prism.Ioc;
using Prism.Properties;
-using Prism.Regions.Behaviors;
+using Prism.Navigation.Regions.Behaviors;
using Prism.Ioc.Internals;
-using Prism.Navigation;
#if HAS_WINUI
using Microsoft.UI.Xaml;
@@ -22,7 +21,7 @@
#endif
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// This class is responsible for maintaining a collection of regions and attaching regions to controls.
@@ -347,7 +346,7 @@ public IRegionManager RegisterViewWithRegion(string regionName, string targetNam
/// The name of the region to associate the view with.
/// The delegate used to resolve a concrete instance of the view.
/// The , for adding several views easily
- public IRegionManager RegisterViewWithRegion(string regionName, Func getContentDelegate)
+ public IRegionManager RegisterViewWithRegion(string regionName, Func getContentDelegate)
{
var regionViewRegistry = ContainerLocator.Container.Resolve();
@@ -377,40 +376,6 @@ public void RequestNavigate(string regionName, Uri source, Action
- /// Navigates the specified region manager.
- ///
- /// The name of the region to call Navigate on.
- /// The URI of the content to display.
- public void RequestNavigate(string regionName, Uri source)
- {
- RequestNavigate(regionName, source, nr => { });
- }
-
- ///
- /// Navigates the specified region manager.
- ///
- /// The name of the region to call Navigate on.
- /// The URI of the content to display.
- /// The navigation callback.
- public void RequestNavigate(string regionName, string source, Action navigationCallback)
- {
- if (source == null)
- throw new ArgumentNullException(nameof(source));
-
- RequestNavigate(regionName, new Uri(source, UriKind.RelativeOrAbsolute), navigationCallback);
- }
-
- ///
- /// Navigates the specified region manager.
- ///
- /// The name of the region to call Navigate on.
- /// The URI of the content to display.
- public void RequestNavigate(string regionName, string source)
- {
- RequestNavigate(regionName, source, nr => { });
- }
-
///
/// This method allows an IRegionManager to locate a specified region and navigate in it to the specified target Uri, passing a navigation callback and an instance of NavigationParameters, which holds a collection of object parameters.
///
@@ -433,40 +398,6 @@ public void RequestNavigate(string regionName, Uri target, Action
- /// This method allows an IRegionManager to locate a specified region and navigate in it to the specified target string, passing a navigation callback and an instance of NavigationParameters, which holds a collection of object parameters.
- ///
- /// The name of the region where the navigation will occur.
- /// A string that represents the target where the region will navigate.
- /// The navigation callback that will be executed after the navigation is completed.
- /// An instance of NavigationParameters, which holds a collection of object parameters.
- public void RequestNavigate(string regionName, string target, Action navigationCallback, INavigationParameters navigationParameters)
- {
- RequestNavigate(regionName, new Uri(target, UriKind.RelativeOrAbsolute), navigationCallback, navigationParameters);
- }
-
- ///
- /// This method allows an IRegionManager to locate a specified region and navigate in it to the specified target Uri, passing an instance of NavigationParameters, which holds a collection of object parameters.
- ///
- /// The name of the region where the navigation will occur.
- /// A Uri that represents the target where the region will navigate.
- /// An instance of NavigationParameters, which holds a collection of object parameters.
- public void RequestNavigate(string regionName, Uri target, INavigationParameters navigationParameters)
- {
- RequestNavigate(regionName, target, nr => { }, navigationParameters);
- }
-
- ///
- /// This method allows an IRegionManager to locate a specified region and navigate in it to the specified target string, passing an instance of NavigationParameters, which holds a collection of object parameters.
- ///
- /// The name of the region where the navigation will occur.
- /// A string that represents the target where the region will navigate.
- /// An instance of NavigationParameters, which holds a collection of object parameters.
- public void RequestNavigate(string regionName, string target, INavigationParameters navigationParameters)
- {
- RequestNavigate(regionName, new Uri(target, UriKind.RelativeOrAbsolute), nr => { }, navigationParameters);
- }
-
///
/// Provides a new item for the region based on the supplied candidate target contract name.
///
diff --git a/src/Wpf/Prism.Wpf/Regions/RegionNavigationContentLoader.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/RegionNavigationContentLoader.cs
similarity index 97%
rename from src/Wpf/Prism.Wpf/Regions/RegionNavigationContentLoader.cs
rename to src/Wpf/Prism.Wpf/Navigation/Regions/RegionNavigationContentLoader.cs
index af4be1ebae..e01de9f7ba 100644
--- a/src/Wpf/Prism.Wpf/Regions/RegionNavigationContentLoader.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/RegionNavigationContentLoader.cs
@@ -14,7 +14,7 @@
#endif
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Implementation of that relies on a
@@ -62,7 +62,7 @@ public object LoadContent(IRegion region, NavigationContext navigationContext)
candidates.Where(
v =>
{
- if (v is INavigationAware navigationAware && !navigationAware.IsNavigationTarget(navigationContext))
+ if (v is IRegionAware navigationAware && !navigationAware.IsNavigationTarget(navigationContext))
{
return false;
}
@@ -72,7 +72,7 @@ public object LoadContent(IRegion region, NavigationContext navigationContext)
return true;
}
- navigationAware = frameworkElement.DataContext as INavigationAware;
+ navigationAware = frameworkElement.DataContext as IRegionAware;
return navigationAware == null || navigationAware.IsNavigationTarget(navigationContext);
});
diff --git a/src/Wpf/Prism.Wpf/Regions/RegionNavigationService.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/RegionNavigationService.cs
similarity index 98%
rename from src/Wpf/Prism.Wpf/Regions/RegionNavigationService.cs
rename to src/Wpf/Prism.Wpf/Navigation/Regions/RegionNavigationService.cs
index a1a2af43b1..069cd710eb 100644
--- a/src/Wpf/Prism.Wpf/Regions/RegionNavigationService.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/RegionNavigationService.cs
@@ -5,7 +5,6 @@
using Prism.Common;
using Prism.Properties;
using Prism.Ioc;
-using Prism.Navigation;
#if HAS_WINUI
using Microsoft.UI.Xaml;
@@ -13,7 +12,7 @@
using System.Windows;
#endif
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Provides navigation for regions.
@@ -240,7 +239,7 @@ private void ExecuteNavigation(NavigationContext navigationContext, object[] act
Journal.RecordNavigation(journalEntry, persistInHistory);
// The view can be informed of navigation
- Action action = (n) => n.OnNavigatedTo(navigationContext);
+ Action action = (n) => n.OnNavigatedTo(navigationContext);
MvvmHelpers.ViewAndViewModelAction(view, action);
navigationCallback(new NavigationResult(navigationContext, true));
@@ -275,7 +274,7 @@ private static void NotifyActiveViewsNavigatingFrom(NavigationContext navigation
InvokeOnNavigationAwareElements(activeViews, (n) => n.OnNavigatedFrom(navigationContext));
}
- private static void InvokeOnNavigationAwareElements(IEnumerable items, Action invocation)
+ private static void InvokeOnNavigationAwareElements(IEnumerable items, Action invocation)
{
foreach (var item in items)
{
diff --git a/src/Wpf/Prism.Wpf/Regions/RegionViewRegistry.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/RegionViewRegistry.cs
similarity index 72%
rename from src/Wpf/Prism.Wpf/Regions/RegionViewRegistry.cs
rename to src/Wpf/Prism.Wpf/Navigation/Regions/RegionViewRegistry.cs
index 90ad8bd671..0ead2d378a 100644
--- a/src/Wpf/Prism.Wpf/Regions/RegionViewRegistry.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/RegionViewRegistry.cs
@@ -7,7 +7,7 @@
using Prism.Ioc;
using Prism.Properties;
-namespace Prism.Regions
+namespace Prism.Navigation.Regions
{
///
/// Defines a registry for the content of the regions used on View Discovery composition.
@@ -15,7 +15,7 @@ namespace Prism.Regions
public class RegionViewRegistry : IRegionViewRegistry
{
private readonly IContainerProvider _container;
- private readonly ListDictionary> _registeredContent = new ListDictionary>();
+ private readonly ListDictionary> _registeredContent = new ListDictionary>();
private readonly WeakDelegatesManager _contentRegisteredListeners = new WeakDelegatesManager();
///
@@ -40,13 +40,14 @@ public event EventHandler ContentRegistered
/// Returns the contents registered for a region.
///
/// Name of the region which content is being requested.
+ /// The to use to get the View.
/// Collection of contents registered for the region.
- public IEnumerable GetContents(string regionName)
+ public IEnumerable GetContents(string regionName, IContainerProvider container)
{
- List items = new List();
- foreach (Func getContentDelegate in _registeredContent[regionName])
+ var items = new List();
+ foreach (Func getContentDelegate in _registeredContent[regionName])
{
- items.Add(getContentDelegate());
+ items.Add(getContentDelegate(container));
}
return items;
@@ -59,22 +60,33 @@ public IEnumerable GetContents(string regionName)
/// Content type to be registered for the .
public void RegisterViewWithRegion(string regionName, Type viewType)
{
- RegisterViewWithRegion(regionName, () => CreateInstance(viewType));
+ RegisterViewWithRegion(regionName, _ => CreateInstance(viewType));
}
///
- /// Registers a delegate that can be used to retrieve the content associated with a region name.
+ /// Registers a delegate that can be used to retrieve the content associated with a region name.
///
/// Region name to which the will be registered.
/// Delegate used to retrieve the content associated with the .
- public void RegisterViewWithRegion(string regionName, Func getContentDelegate)
+ public void RegisterViewWithRegion(string regionName, Func