diff --git a/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/AutoPopulateRegionBehavior.cs b/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/AutoPopulateRegionBehavior.cs
index 5f2b4397a8..0216939507 100644
--- a/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/AutoPopulateRegionBehavior.cs
+++ b/src/Maui/Prism.Maui/Navigation/Regions/Behaviors/AutoPopulateRegionBehavior.cs
@@ -1,4 +1,4 @@
-using System.ComponentModel;
+using System.ComponentModel;
using Prism.Ioc;
namespace Prism.Navigation.Regions.Behaviors;
@@ -61,7 +61,7 @@ private void StartPopulatingContent()
var registration = registry.Registrations.FirstOrDefault(x => x.View == type);
if (registration is not null)
{
- var view = registry.CreateView(container, registration.Name) as VisualElement;
+ var view = registry.CreateView(container, registration.Name);
Region.Add(view);
}
}
diff --git a/src/Uno/Prism.Uno/Navigation/Regions/NavigationViewRegionAdapter.cs b/src/Uno/Prism.Uno/Navigation/Regions/NavigationViewRegionAdapter.cs
index 83fcd12d1f..eb9411bf0b 100644
--- a/src/Uno/Prism.Uno/Navigation/Regions/NavigationViewRegionAdapter.cs
+++ b/src/Uno/Prism.Uno/Navigation/Regions/NavigationViewRegionAdapter.cs
@@ -27,8 +27,8 @@ protected override void Adapt(IRegion region, NavigationView regionTarget)
};
}
- protected override IRegion CreateRegion()
+ protected override IRegion CreateRegion(object regionTarget)
{
- return new SingleActiveRegion();
+ return new SingleActiveRegion(regionTarget);
}
}
diff --git a/src/Wpf/Prism.Wpf/Navigation/Regions/AllActiveRegion.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/AllActiveRegion.cs
index e26302aee0..7bb08ac6f1 100644
--- a/src/Wpf/Prism.Wpf/Navigation/Regions/AllActiveRegion.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/AllActiveRegion.cs
@@ -5,7 +5,7 @@ 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 class AllActiveRegion(object target) : Region(target)
{
///
/// Gets a readonly view of the collection of all the active views in the region. These are all the added views.
diff --git a/src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/AutoPopulateRegionBehavior.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/AutoPopulateRegionBehavior.cs
index 10ae82ea94..0ed47777a4 100644
--- a/src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/AutoPopulateRegionBehavior.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/Behaviors/AutoPopulateRegionBehavior.cs
@@ -44,6 +44,22 @@ private void StartPopulatingContent()
AddViewIntoRegion(view);
}
+ if (Region is ITargetAwareRegion targetAware && targetAware.Target is FrameworkElement target
+ && target.GetValue(RegionManager.DefaultViewProperty) != null)
+ {
+ var defaultView = target.GetValue(RegionManager.DefaultViewProperty);
+ if (defaultView is string targetName)
+ Region.Add(targetName);
+ else if (defaultView is UIElement element)
+ Region.Add(element);
+ else if (defaultView is Type type)
+ {
+ var container = ContainerLocator.Container;
+ var view = container.Resolve(type);
+ Region.Add(view);
+ }
+ }
+
regionViewRegistry.ContentRegistered += OnViewRegistered;
}
diff --git a/src/Wpf/Prism.Wpf/Navigation/Regions/ContentControlRegionAdapter.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/ContentControlRegionAdapter.cs
index 52aa7a991c..a3b4827b36 100644
--- a/src/Wpf/Prism.Wpf/Navigation/Regions/ContentControlRegionAdapter.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/ContentControlRegionAdapter.cs
@@ -53,9 +53,9 @@ protected override void Adapt(IRegion region, ContentControl regionTarget)
/// Creates a new instance of .
///
/// A new instance of .
- protected override IRegion CreateRegion()
+ protected override IRegion CreateRegion(object regionTarget)
{
- return new SingleActiveRegion();
+ return new SingleActiveRegion(regionTarget);
}
}
}
diff --git a/src/Wpf/Prism.Wpf/Navigation/Regions/ITargetAwareRegion.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/ITargetAwareRegion.cs
new file mode 100644
index 0000000000..fb5a807480
--- /dev/null
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/ITargetAwareRegion.cs
@@ -0,0 +1,6 @@
+namespace Prism.Navigation.Regions;
+
+public interface ITargetAwareRegion : IRegion
+{
+ object Target { get; }
+}
diff --git a/src/Wpf/Prism.Wpf/Navigation/Regions/ItemsControlRegionAdapter.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/ItemsControlRegionAdapter.cs
index 6ff23fc583..0ac7f6ffab 100644
--- a/src/Wpf/Prism.Wpf/Navigation/Regions/ItemsControlRegionAdapter.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/ItemsControlRegionAdapter.cs
@@ -56,9 +56,9 @@ protected override void Adapt(IRegion region, ItemsControl regionTarget)
/// Creates a new instance of .
///
/// A new instance of .
- protected override IRegion CreateRegion()
+ protected override IRegion CreateRegion(object regionTarget)
{
- return new AllActiveRegion();
+ return new AllActiveRegion(regionTarget);
}
}
}
diff --git a/src/Wpf/Prism.Wpf/Navigation/Regions/Region.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/Region.cs
index 624f49fb24..17a4bbb0a8 100644
--- a/src/Wpf/Prism.Wpf/Navigation/Regions/Region.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/Region.cs
@@ -8,7 +8,7 @@ namespace Prism.Navigation.Regions
///
/// Implementation of that allows multiple active views.
///
- public class Region : IRegion
+ public class Region : ITargetAwareRegion
{
private ObservableCollection _itemMetadataCollection;
private string _name;
@@ -23,13 +23,20 @@ public class Region : IRegion
///
/// Initializes a new instance of .
///
- public Region()
+ /// The target view of the Region
+ public Region(object target)
{
Behaviors = new RegionBehaviorCollection(this);
+ Target = target;
_sort = DefaultSortComparison;
}
+ ///
+ /// Gets the target view of the Region.
+ ///
+ public object Target { get; }
+
///
/// Occurs when a property value changes.
///
diff --git a/src/Wpf/Prism.Wpf/Navigation/Regions/RegionAdapterBase.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/RegionAdapterBase.cs
index d8523d36a6..5d7f82d8c6 100644
--- a/src/Wpf/Prism.Wpf/Navigation/Regions/RegionAdapterBase.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/RegionAdapterBase.cs
@@ -35,7 +35,7 @@ public IRegion Initialize(T regionTarget, string regionName)
if (regionName == null)
throw new ArgumentNullException(nameof(regionName));
- IRegion region = CreateRegion();
+ IRegion region = CreateRegion(regionTarget);
region.Name = regionName;
SetObservableRegionOnHostingControl(region, regionTarget);
@@ -121,7 +121,7 @@ protected virtual void AttachBehaviors(IRegion region, T regionTarget)
/// that will be used to adapt the object.
///
/// A new instance of .
- protected abstract IRegion CreateRegion();
+ protected abstract IRegion CreateRegion(object regionTarget);
private static T GetCastedObject(object regionTarget)
{
diff --git a/src/Wpf/Prism.Wpf/Navigation/Regions/RegionManager.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/RegionManager.cs
index 4ac125e9e5..26c0c25334 100644
--- a/src/Wpf/Prism.Wpf/Navigation/Regions/RegionManager.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/RegionManager.cs
@@ -67,6 +67,40 @@ public static string GetRegionName(DependencyObject regionTarget)
return regionTarget.GetValue(RegionNameProperty) as string;
}
+ ///
+ /// Sets the DefaultView on the specified region
+ ///
+ public static readonly DependencyProperty DefaultViewProperty =
+ DependencyProperty.RegisterAttached("DefaultView", typeof(object), typeof(RegionManager), null);
+
+ ///
+ /// Gets the Default View Instance, Type or Name
+ ///
+ /// The Region Target View
+ ///
+ ///
+ public static object GetDefaultView(DependencyObject regionTarget)
+ {
+ if (regionTarget == null)
+ throw new ArgumentNullException(nameof(regionTarget));
+
+ return regionTarget.GetValue(DefaultViewProperty);
+ }
+
+ ///
+ /// Sets the Default Region View Instance, Type or Name.
+ ///
+ /// The Region Target.
+ /// The view instance, type or name.
+ ///
+ public static void SetDefaultView(DependencyObject regionTarget, object viewNameTypeOrInstance)
+ {
+ if (regionTarget == null)
+ throw new ArgumentNullException(nameof(regionTarget));
+
+ regionTarget.SetValue(DefaultViewProperty, viewNameTypeOrInstance);
+ }
+
private static readonly DependencyProperty ObservableRegionProperty =
DependencyProperty.RegisterAttached("ObservableRegion", typeof(ObservableObject), typeof(RegionManager), null);
diff --git a/src/Wpf/Prism.Wpf/Navigation/Regions/SelectorRegionAdapter.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/SelectorRegionAdapter.cs
index 87bbd7ce6c..3d4b007216 100644
--- a/src/Wpf/Prism.Wpf/Navigation/Regions/SelectorRegionAdapter.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/SelectorRegionAdapter.cs
@@ -55,9 +55,9 @@ protected override void AttachBehaviors(IRegion region, Selector regionTarget)
/// Creates a new instance of .
///
/// A new instance of .
- protected override IRegion CreateRegion()
+ protected override IRegion CreateRegion(object regionTarget)
{
- return new Region();
+ return new Region(regionTarget);
}
}
}
diff --git a/src/Wpf/Prism.Wpf/Navigation/Regions/SingleActiveRegion.cs b/src/Wpf/Prism.Wpf/Navigation/Regions/SingleActiveRegion.cs
index 45f0b299f1..c12c934250 100644
--- a/src/Wpf/Prism.Wpf/Navigation/Regions/SingleActiveRegion.cs
+++ b/src/Wpf/Prism.Wpf/Navigation/Regions/SingleActiveRegion.cs
@@ -3,7 +3,7 @@ namespace Prism.Navigation.Regions
///
/// Region that allows a maximum of one active view at a time.
///
- public class SingleActiveRegion : Region
+ public class SingleActiveRegion(object target) : Region(target)
{
///
/// Marks the specified view as active.
diff --git a/tests/Wpf/Prism.Container.Wpf.Shared/Fixtures/Regions/RegionNavigationContentLoaderFixture.cs b/tests/Wpf/Prism.Container.Wpf.Shared/Fixtures/Regions/RegionNavigationContentLoaderFixture.cs
index 2a49859e23..054b1bb154 100644
--- a/tests/Wpf/Prism.Container.Wpf.Shared/Fixtures/Regions/RegionNavigationContentLoaderFixture.cs
+++ b/tests/Wpf/Prism.Container.Wpf.Shared/Fixtures/Regions/RegionNavigationContentLoaderFixture.cs
@@ -1,4 +1,4 @@
-using System.Linq;
+using System.Linq;
using Prism.Ioc;
using Prism.IocContainer.Wpf.Tests.Support.Mocks.Views;
using Prism.Navigation.Regions;
@@ -31,7 +31,7 @@ public void ShouldFindCandidateViewInRegion()
// We cannot access the UnityRegionNavigationContentLoader directly so we need to call its
// GetCandidatesFromRegion method through a navigation request.
- IRegion testRegion = new Region();
+ IRegion testRegion = new Region(new ContentControl());
MockView view = new MockView();
testRegion.Add(view);
@@ -54,7 +54,7 @@ public void ShouldFindCandidateViewWithFriendlyNameInRegion()
// We cannot access the Container specific RegionNavigationContentLoader directly so we need to call its
// GetCandidatesFromRegion method through a navigation request.
- IRegion testRegion = new Region();
+ IRegion testRegion = new Region(new ContentControl());
var view = _container.Resolve("SomeView") as MockView;
testRegion.Add(view);
diff --git a/tests/Wpf/Prism.Wpf.Tests/Regions/AllActiveRegionFixture.cs b/tests/Wpf/Prism.Wpf.Tests/Regions/AllActiveRegionFixture.cs
index 526174dc60..f229a010c5 100644
--- a/tests/Wpf/Prism.Wpf.Tests/Regions/AllActiveRegionFixture.cs
+++ b/tests/Wpf/Prism.Wpf.Tests/Regions/AllActiveRegionFixture.cs
@@ -12,7 +12,7 @@ public class AllActiveRegionFixture
public void AddingViewsToRegionMarksThemAsActive()
{
ContainerLocator.SetContainerExtension(Mock.Of());
- IRegion region = new AllActiveRegion();
+ IRegion region = new AllActiveRegion(new ItemsControl());
var view = new object();
region.Add(view);
@@ -25,7 +25,7 @@ public void DeactivateThrows()
{
var ex = Assert.Throws(() =>
{
- IRegion region = new AllActiveRegion();
+ IRegion region = new AllActiveRegion(new ItemsControl());
var view = new object();
region.Add(view);
diff --git a/tests/Wpf/Prism.Wpf.Tests/Regions/Behaviors/ClearChildViewsRegionBehaviorFixture.cs b/tests/Wpf/Prism.Wpf.Tests/Regions/Behaviors/ClearChildViewsRegionBehaviorFixture.cs
index a5498594a7..23bba2a6b4 100644
--- a/tests/Wpf/Prism.Wpf.Tests/Regions/Behaviors/ClearChildViewsRegionBehaviorFixture.cs
+++ b/tests/Wpf/Prism.Wpf.Tests/Regions/Behaviors/ClearChildViewsRegionBehaviorFixture.cs
@@ -15,7 +15,7 @@ public void WhenClearChildViewsPropertyIsNotSet_ThenChildViewsRegionManagerIsNot
{
var regionManager = new MockRegionManager();
- var region = new Region();
+ var region = new Region(new ContentControl());
region.RegionManager = regionManager;
var behavior = new ClearChildViewsRegionBehavior();
@@ -37,7 +37,7 @@ public void WhenClearChildViewsPropertyIsTrue_ThenChildViewsRegionManagerIsClear
{
var regionManager = new MockRegionManager();
- var region = new Region();
+ var region = new Region(new ContentControl());
region.RegionManager = regionManager;
var behavior = new ClearChildViewsRegionBehavior();
@@ -61,7 +61,7 @@ public void WhenRegionManagerChangesToNotNullValue_ThenChildViewsRegionManagerIs
{
var regionManager = new MockRegionManager();
- var region = new Region();
+ var region = new Region(new ContentControl());
region.RegionManager = regionManager;
var behavior = new ClearChildViewsRegionBehavior();
diff --git a/tests/Wpf/Prism.Wpf.Tests/Regions/Behaviors/RegionActiveAwareBehaviorFixture.cs b/tests/Wpf/Prism.Wpf.Tests/Regions/Behaviors/RegionActiveAwareBehaviorFixture.cs
index d0f57ac893..2d1c792b48 100644
--- a/tests/Wpf/Prism.Wpf.Tests/Regions/Behaviors/RegionActiveAwareBehaviorFixture.cs
+++ b/tests/Wpf/Prism.Wpf.Tests/Regions/Behaviors/RegionActiveAwareBehaviorFixture.cs
@@ -131,7 +131,7 @@ public void DoesNotThrowWhenAddingNonActiveAwareDataContexts()
public void WhenParentViewGetsActivatedOrDeactivated_ThenChildViewIsNotUpdated()
{
var scopedRegionManager = new RegionManager();
- var scopedRegion = new Region { Name = "MyScopedRegion", RegionManager = scopedRegionManager };
+ var scopedRegion = new Region(new ContentControl()) { Name = "MyScopedRegion", RegionManager = scopedRegionManager };
scopedRegionManager.Regions.Add(scopedRegion);
var behaviorForScopedRegion = new RegionActiveAwareBehavior { Region = scopedRegion };
behaviorForScopedRegion.Attach();
@@ -160,7 +160,7 @@ public void WhenParentViewGetsActivatedOrDeactivated_ThenChildViewIsNotUpdated()
public void WhenParentViewGetsActivatedOrDeactivated_ThenSyncedChildViewIsUpdated()
{
var scopedRegionManager = new RegionManager();
- var scopedRegion = new Region { Name = "MyScopedRegion", RegionManager = scopedRegionManager };
+ var scopedRegion = new Region(new ContentControl()) { Name = "MyScopedRegion", RegionManager = scopedRegionManager };
scopedRegionManager.Regions.Add(scopedRegion);
var behaviorForScopedRegion = new RegionActiveAwareBehavior { Region = scopedRegion };
behaviorForScopedRegion.Attach();
@@ -189,7 +189,7 @@ public void WhenParentViewGetsActivatedOrDeactivated_ThenSyncedChildViewIsUpdate
public void WhenParentViewGetsActivatedOrDeactivated_ThenSyncedChildViewWithAttributeInVMIsUpdated()
{
var scopedRegionManager = new RegionManager();
- var scopedRegion = new Region { Name = "MyScopedRegion", RegionManager = scopedRegionManager };
+ var scopedRegion = new Region(new ContentControl()) { Name = "MyScopedRegion", RegionManager = scopedRegionManager };
scopedRegionManager.Regions.Add(scopedRegion);
var behaviorForScopedRegion = new RegionActiveAwareBehavior { Region = scopedRegion };
behaviorForScopedRegion.Attach();
@@ -219,7 +219,7 @@ public void WhenParentViewGetsActivatedOrDeactivated_ThenSyncedChildViewWithAttr
public void WhenParentViewGetsActivatedOrDeactivated_ThenSyncedChildViewModelThatIsNotAFrameworkElementIsNotUpdated()
{
var scopedRegionManager = new RegionManager();
- var scopedRegion = new Region { Name = "MyScopedRegion", RegionManager = scopedRegionManager };
+ var scopedRegion = new Region(new ContentControl()) { Name = "MyScopedRegion", RegionManager = scopedRegionManager };
scopedRegionManager.Regions.Add(scopedRegion);
var behaviorForScopedRegion = new RegionActiveAwareBehavior { Region = scopedRegion };
behaviorForScopedRegion.Attach();
@@ -248,7 +248,7 @@ public void WhenParentViewGetsActivatedOrDeactivated_ThenSyncedChildViewModelTha
public void WhenParentViewGetsActivatedOrDeactivated_ThenSyncedChildViewNotInActiveViewsIsNotUpdated()
{
var scopedRegionManager = new RegionManager();
- var scopedRegion = new Region { Name = "MyScopedRegion", RegionManager = scopedRegionManager };
+ var scopedRegion = new Region(new ContentControl()) { Name = "MyScopedRegion", RegionManager = scopedRegionManager };
scopedRegionManager.Regions.Add(scopedRegion);
var behaviorForScopedRegion = new RegionActiveAwareBehavior { Region = scopedRegion };
behaviorForScopedRegion.Attach();
@@ -281,7 +281,7 @@ public void WhenParentViewGetsActivatedOrDeactivated_ThenSyncedChildViewNotInAct
public void WhenParentViewWithoutScopedRegionGetsActivatedOrDeactivated_ThenSyncedChildViewIsNotUpdated()
{
var commonRegionManager = new RegionManager();
- var nonScopedRegion = new Region { Name = "MyRegion", RegionManager = commonRegionManager };
+ var nonScopedRegion = new Region(new ContentControl()) { Name = "MyRegion", RegionManager = commonRegionManager };
commonRegionManager.Regions.Add(nonScopedRegion);
var behaviorForScopedRegion = new RegionActiveAwareBehavior { Region = nonScopedRegion };
behaviorForScopedRegion.Attach();
diff --git a/tests/Wpf/Prism.Wpf.Tests/Regions/Behaviors/RegionMemberLifetimeBehaviorFixture.cs b/tests/Wpf/Prism.Wpf.Tests/Regions/Behaviors/RegionMemberLifetimeBehaviorFixture.cs
index 3802c1948a..9583733dd7 100644
--- a/tests/Wpf/Prism.Wpf.Tests/Regions/Behaviors/RegionMemberLifetimeBehaviorFixture.cs
+++ b/tests/Wpf/Prism.Wpf.Tests/Regions/Behaviors/RegionMemberLifetimeBehaviorFixture.cs
@@ -21,10 +21,10 @@ public RegionMemberLifetimeBehaviorFixture()
protected virtual void Arrange()
{
- this.Region = new Region();
- this.Behavior = new RegionMemberLifetimeBehavior();
- this.Behavior.Region = this.Region;
- this.Behavior.Attach();
+ Region = new Region(new ContentControl());
+ Behavior = new RegionMemberLifetimeBehavior();
+ Behavior.Region = Region;
+ Behavior.Attach();
}
[Fact]
@@ -257,10 +257,10 @@ public class RegionMemberLifetimeBehaviorAgainstSingleActiveRegionFixture
{
protected override void Arrange()
{
- this.Region = new SingleActiveRegion();
- this.Behavior = new RegionMemberLifetimeBehavior();
- this.Behavior.Region = this.Region;
- this.Behavior.Attach();
+ Region = new SingleActiveRegion(new ContentControl());
+ Behavior = new RegionMemberLifetimeBehavior();
+ Behavior.Region = Region;
+ Behavior.Attach();
}
}
}
diff --git a/tests/Wpf/Prism.Wpf.Tests/Regions/Behaviors/SelectorItemsSourceSyncRegionBehaviorFixture.cs b/tests/Wpf/Prism.Wpf.Tests/Regions/Behaviors/SelectorItemsSourceSyncRegionBehaviorFixture.cs
index 35c26fc137..a1bc897b46 100644
--- a/tests/Wpf/Prism.Wpf.Tests/Regions/Behaviors/SelectorItemsSourceSyncRegionBehaviorFixture.cs
+++ b/tests/Wpf/Prism.Wpf.Tests/Regions/Behaviors/SelectorItemsSourceSyncRegionBehaviorFixture.cs
@@ -208,7 +208,7 @@ public void ShouldAllowMultipleSelectedItemsForListBox()
private SelectorItemsSourceSyncBehavior CreateBehavior()
{
- Region region = new Region();
+ Region region = new Region(new ContentControl());
Selector selector = new TabControl();
var behavior = new SelectorItemsSourceSyncBehavior();
diff --git a/tests/Wpf/Prism.Wpf.Tests/Regions/ContentControlRegionAdapterFixture.cs b/tests/Wpf/Prism.Wpf.Tests/Regions/ContentControlRegionAdapterFixture.cs
index 0027a4063a..1c82189cba 100644
--- a/tests/Wpf/Prism.Wpf.Tests/Regions/ContentControlRegionAdapterFixture.cs
+++ b/tests/Wpf/Prism.Wpf.Tests/Regions/ContentControlRegionAdapterFixture.cs
@@ -158,7 +158,7 @@ public TestableContentControlRegionAdapter() : base(null)
private MockPresentationRegion region = new MockPresentationRegion();
- protected override IRegion CreateRegion()
+ protected override IRegion CreateRegion(object regionTarget)
{
return region;
}
diff --git a/tests/Wpf/Prism.Wpf.Tests/Regions/ItemsControlRegionAdapterFixture.cs b/tests/Wpf/Prism.Wpf.Tests/Regions/ItemsControlRegionAdapterFixture.cs
index e75d6b0297..dec0caa80c 100644
--- a/tests/Wpf/Prism.Wpf.Tests/Regions/ItemsControlRegionAdapterFixture.cs
+++ b/tests/Wpf/Prism.Wpf.Tests/Regions/ItemsControlRegionAdapterFixture.cs
@@ -111,7 +111,7 @@ public TestableItemsControlRegionAdapter() : base(null)
private MockPresentationRegion region = new MockPresentationRegion();
- protected override IRegion CreateRegion()
+ protected override IRegion CreateRegion(object regionTarget)
{
return region;
}
diff --git a/tests/Wpf/Prism.Wpf.Tests/Regions/LocatorNavigationTargetHandlerFixture.cs b/tests/Wpf/Prism.Wpf.Tests/Regions/LocatorNavigationTargetHandlerFixture.cs
index 8f1c1afa5f..47e3835082 100644
--- a/tests/Wpf/Prism.Wpf.Tests/Regions/LocatorNavigationTargetHandlerFixture.cs
+++ b/tests/Wpf/Prism.Wpf.Tests/Regions/LocatorNavigationTargetHandlerFixture.cs
@@ -19,7 +19,7 @@ public void WhenViewExistsAndDoesNotImplementINavigationAware_ThenReturnsView()
var containerMock = new Mock();
ContainerLocator.SetContainerExtension(containerMock.Object);
- var region = new Region();
+ var region = new Region(new ContentControl());
var view = new TestView();
@@ -48,7 +48,7 @@ public void WhenRegionHasMultipleViews_ThenViewsWithMatchingTypeNameAreConsidere
var containerMock = new Mock();
ContainerLocator.SetContainerExtension(containerMock.Object);
- var region = new Region();
+ var region = new Region(new ContentControl());
var view1 = new TestView();
var view2 = new Test2View();
@@ -79,7 +79,7 @@ public void WhenRegionHasMultipleViews_ThenViewsWithMatchingFullTypeNameAreConsi
var containerMock = new Mock();
ContainerLocator.SetContainerExtension(containerMock.Object);
- var region = new Region();
+ var region = new Region(new ContentControl());
var view1 = new TestView();
var view2 = new Test2View();
@@ -110,7 +110,7 @@ public void WhenViewExistsAndImplementsINavigationAware_ThenViewIsQueriedForNavi
var containerMock = new Mock();
ContainerLocator.SetContainerExtension(containerMock.Object);
- var region = new Region();
+ var region = new Region(new ContentControl());
var viewMock = new Mock();
viewMock
@@ -144,7 +144,7 @@ public void WhenViewExistsAndHasDataContextThatImplementsINavigationAware_ThenDa
var containerMock = new Mock();
ContainerLocator.SetContainerExtension(containerMock.Object);
- var region = new Region();
+ var region = new Region(new ContentControl());
var dataContextMock = new Mock();
dataContextMock
@@ -180,7 +180,7 @@ public void WhenNoCurrentMatchingViewExists_ThenReturnsNewlyCreatedInstanceWithS
var containerMock = new Mock();
ContainerLocator.SetContainerExtension(containerMock.Object);
- var region = new Region();
+ var region = new Region(new ContentControl());
var view = new TestView();
@@ -210,7 +210,7 @@ public void WhenViewExistsAndImplementsINavigationAware_ThenViewIsQueriedForNavi
var containerMock = new Mock();
ContainerLocator.SetContainerExtension(containerMock.Object);
- var region = new Region();
+ var region = new Region(new ContentControl());
var viewMock = new Mock();
viewMock
@@ -248,7 +248,7 @@ public void WhenViewExistsAndHasDataContextThatImplementsINavigationAware_ThenDa
var containerMock = new Mock();
ContainerLocator.SetContainerExtension(containerMock.Object);
- var region = new Region();
+ var region = new Region(new ContentControl());
var dataContextMock = new Mock();
dataContextMock
@@ -285,7 +285,7 @@ public void WhenViewCannotBeCreated_ThenThrowsAnException()
containerMock.Setup(sl => sl.Resolve(typeof(object), typeof(TestView).Name)).Throws();
- var region = new Region();
+ var region = new Region(new ContentControl());
var navigationContext = new NavigationContext(null, new Uri(typeof(TestView).Name, UriKind.Relative));
@@ -308,7 +308,7 @@ public void WhenViewAddedByHandlerDoesNotImplementINavigationAware_ThenReturnsVi
var containerMock = new Mock();
ContainerLocator.SetContainerExtension(containerMock.Object);
- var region = new Region();
+ var region = new Region(new ContentControl());
var view = new TestView();
@@ -352,7 +352,7 @@ public void WhenRequestingContentForNullContext_ThenThrows()
var containerMock = new Mock();
ContainerLocator.SetContainerExtension(containerMock.Object);
- var region = new Region();
+ var region = new Region(new ContentControl());
var navigationTargetHandler = new TestRegionNavigationContentLoader(containerMock.Object);
diff --git a/tests/Wpf/Prism.Wpf.Tests/Regions/NavigationContextFixture.cs b/tests/Wpf/Prism.Wpf.Tests/Regions/NavigationContextFixture.cs
index f362adf918..1fcd5b9381 100644
--- a/tests/Wpf/Prism.Wpf.Tests/Regions/NavigationContextFixture.cs
+++ b/tests/Wpf/Prism.Wpf.Tests/Regions/NavigationContextFixture.cs
@@ -17,7 +17,7 @@ public void WhenCreatingANewContextForAUriWithAQuery_ThenNewContextInitializesPr
var navigationJournalMock = new Mock();
var navigationServiceMock = new Mock();
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
navigationServiceMock.SetupGet(n => n.Region).Returns(region);
navigationServiceMock.SetupGet(x => x.Journal).Returns(navigationJournalMock.Object);
diff --git a/tests/Wpf/Prism.Wpf.Tests/Regions/RegionAdapterBaseFixture.cs b/tests/Wpf/Prism.Wpf.Tests/Regions/RegionAdapterBaseFixture.cs
index c7c0da4b50..63b61df444 100644
--- a/tests/Wpf/Prism.Wpf.Tests/Regions/RegionAdapterBaseFixture.cs
+++ b/tests/Wpf/Prism.Wpf.Tests/Regions/RegionAdapterBaseFixture.cs
@@ -94,7 +94,7 @@ protected override void Adapt(IRegion region, MockRegionTarget regionTarget)
adaptArgumentRegionTarget = regionTarget;
}
- protected override IRegion CreateRegion()
+ protected override IRegion CreateRegion(object regionTarget)
{
return CreateRegionReturnValue;
}
diff --git a/tests/Wpf/Prism.Wpf.Tests/Regions/RegionFixture.cs b/tests/Wpf/Prism.Wpf.Tests/Regions/RegionFixture.cs
index f126de6208..5bcec186a8 100644
--- a/tests/Wpf/Prism.Wpf.Tests/Regions/RegionFixture.cs
+++ b/tests/Wpf/Prism.Wpf.Tests/Regions/RegionFixture.cs
@@ -16,7 +16,7 @@ public class RegionFixture
public void WhenRegionConstructed_SortComparisonIsDefault()
{
ContainerLocator.SetContainerExtension(Mock.Of());
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
Assert.NotNull(region.SortComparison);
Assert.Equal(region.SortComparison, Region.DefaultSortComparison);
@@ -26,7 +26,7 @@ public void WhenRegionConstructed_SortComparisonIsDefault()
public void CanAddContentToRegion()
{
ContainerLocator.SetContainerExtension(Mock.Of());
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
Assert.Empty(region.Views.Cast());
@@ -39,7 +39,7 @@ public void CanAddContentToRegion()
[Fact]
public void CanRemoveContentFromRegion()
{
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
object view = new object();
region.Add(view);
@@ -53,7 +53,7 @@ public void RemoveInexistentViewThrows()
{
var ex = Assert.Throws(() =>
{
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
object view = new object();
region.Remove(view);
@@ -67,7 +67,7 @@ public void RemoveInexistentViewThrows()
public void RegionExposesCollectionOfContainedViews()
{
ContainerLocator.SetContainerExtension(Mock.Of());
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
object view = new object();
@@ -84,7 +84,7 @@ public void RegionExposesCollectionOfContainedViews()
public void CanAddAndRetrieveNamedViewInstance()
{
ContainerLocator.SetContainerExtension(Mock.Of());
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
object myView = new object();
region.Add(myView, "MyView");
object returnedView = region.GetView("MyView");
@@ -98,7 +98,7 @@ public void AddingDuplicateNamedViewThrows()
{
var ex = Assert.Throws(() =>
{
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
region.Add(new object(), "MyView");
region.Add(new object(), "MyView");
@@ -110,7 +110,7 @@ public void AddingDuplicateNamedViewThrows()
public void AddNamedViewIsAlsoListedInViewsCollection()
{
ContainerLocator.SetContainerExtension(Mock.Of());
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
object myView = new object();
region.Add(myView, "MyView");
@@ -122,7 +122,7 @@ public void AddNamedViewIsAlsoListedInViewsCollection()
[Fact]
public void GetViewReturnsNullWhenViewDoesNotExistInRegion()
{
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
Assert.Null(region.GetView("InexistentView"));
}
@@ -133,7 +133,7 @@ public void GetViewWithNullOrEmptyStringThrows()
{
var ex = Assert.Throws(() =>
{
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
region.GetView(string.Empty);
});
@@ -146,7 +146,7 @@ public void AddNamedViewWithNullOrEmptyStringNameThrows()
ContainerLocator.SetContainerExtension(Mock.Of());
var ex = Assert.Throws(() =>
{
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
region.Add(new object(), string.Empty);
});
@@ -157,7 +157,7 @@ public void AddNamedViewWithNullOrEmptyStringNameThrows()
public void GetViewReturnsNullAfterRemovingViewFromRegion()
{
ContainerLocator.SetContainerExtension(Mock.Of());
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
object myView = new object();
region.Add(myView, "MyView");
region.Remove(myView);
@@ -169,7 +169,7 @@ public void GetViewReturnsNullAfterRemovingViewFromRegion()
public void AddViewPassesSameScopeByDefaultToView()
{
var regionManager = new MockRegionManager();
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
region.RegionManager = regionManager;
var myView = new MockDependencyObject();
@@ -183,7 +183,7 @@ public void AddViewPassesSameScopeByDefaultToNamedView()
{
ContainerLocator.SetContainerExtension(Mock.Of());
var regionManager = new MockRegionManager();
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
region.RegionManager = regionManager;
var myView = new MockDependencyObject();
@@ -197,7 +197,7 @@ public void AddViewPassesDifferentScopeWhenAdding()
{
ContainerLocator.SetContainerExtension(Mock.Of());
var regionManager = new MockRegionManager();
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
region.RegionManager = regionManager;
var myView = new MockDependencyObject();
@@ -212,7 +212,7 @@ public void CreatingNewScopesAsksTheRegionManagerForNewInstance()
ContainerLocator.SetContainerExtension(Mock.Of());
ContainerLocator.SetContainerExtension(Mock.Of());
var regionManager = new MockRegionManager();
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
region.RegionManager = regionManager;
var myView = new object();
@@ -226,7 +226,7 @@ public void AddViewReturnsExistingRegionManager()
{
ContainerLocator.SetContainerExtension(Mock.Of());
var regionManager = new MockRegionManager();
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
region.RegionManager = regionManager;
var myView = new object();
@@ -239,7 +239,7 @@ public void AddViewReturnsExistingRegionManager()
public void AddViewReturnsNewRegionManager()
{
var regionManager = new MockRegionManager();
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
region.RegionManager = regionManager;
var myView = new object();
@@ -251,7 +251,7 @@ public void AddViewReturnsNewRegionManager()
[Fact]
public void AddingNonDependencyObjectToRegionDoesNotThrow()
{
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
object model = new object();
region.Add(model);
@@ -264,7 +264,7 @@ public void ActivateNonAddedViewThrows()
{
var ex = Assert.Throws(() =>
{
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
object nonAddedView = new object();
@@ -278,7 +278,7 @@ public void DeactivateNonAddedViewThrows()
{
var ex = Assert.Throws(() =>
{
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
object nonAddedView = new object();
@@ -292,7 +292,7 @@ public void ActivateNullViewThrows()
{
var ex = Assert.Throws(() =>
{
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
region.Activate(null);
});
@@ -305,7 +305,7 @@ public void AddViewRaisesCollectionViewEvent()
ContainerLocator.SetContainerExtension(Mock.Of());
bool viewAddedCalled = false;
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
region.Views.CollectionChanged += (sender, e) =>
{
if (e.Action == NotifyCollectionChangedAction.Add)
@@ -325,7 +325,7 @@ public void ViewAddedEventPassesTheViewAddedInTheEventArgs()
ContainerLocator.SetContainerExtension(Mock.Of());
object viewAdded = null;
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
region.Views.CollectionChanged += (sender, e) =>
{
if (e.Action == NotifyCollectionChangedAction.Add)
@@ -347,7 +347,7 @@ public void RemoveViewFiresViewRemovedEvent()
ContainerLocator.SetContainerExtension(Mock.Of());
bool viewRemoved = false;
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
object model = new object();
region.Views.CollectionChanged += (sender, e) =>
{
@@ -369,7 +369,7 @@ public void ViewRemovedEventPassesTheViewRemovedInTheEventArgs()
ContainerLocator.SetContainerExtension(Mock.Of());
object removedView = null;
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
region.Views.CollectionChanged += (sender, e) =>
{
if (e.Action == NotifyCollectionChangedAction.Remove)
@@ -389,7 +389,7 @@ public void ShowViewFiresViewShowedEvent()
{
bool viewActivated = false;
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
object model = new object();
region.ActiveViews.CollectionChanged += (o, e) =>
{
@@ -408,7 +408,7 @@ public void ShowViewFiresViewShowedEvent()
public void AddingSameViewTwiceThrows()
{
object view = new object();
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
region.Add(view);
try
@@ -430,7 +430,7 @@ public void AddingSameViewTwiceThrows()
public void RemovingViewAlsoRemovesItFromActiveViews()
{
ContainerLocator.SetContainerExtension(Mock.Of());
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
object model = new object();
region.Add(model);
region.Activate(model);
@@ -445,7 +445,7 @@ public void RemovingViewAlsoRemovesItFromActiveViews()
public void ShouldGetNotificationWhenContextChanges()
{
ContainerLocator.SetContainerExtension(Mock.Of());
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
bool contextChanged = false;
region.PropertyChanged += (s, args) => { if (args.PropertyName == "Context") contextChanged = true; };
@@ -459,7 +459,7 @@ public void ChangingNameOnceItIsSetThrows()
{
var ex = Assert.Throws(() =>
{
- var region = new Region
+ var region = new Region(new ContentControl())
{
Name = "MyRegion"
};
@@ -566,7 +566,7 @@ public void NavigateDelegatesToIRegionNavigationService()
try
{
// Prepare
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
object view = new object();
region.Add(view);
@@ -599,7 +599,7 @@ public void NavigateDelegatesToIRegionNavigationService()
public void WhenViewsWithSortHintsAdded_RegionSortsViews()
{
ContainerLocator.SetContainerExtension(Mock.Of());
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
object view1 = new ViewOrder1();
object view2 = new ViewOrder2();
@@ -619,7 +619,7 @@ public void WhenViewsWithSortHintsAdded_RegionSortsViews()
public void WhenViewHasBeenRemovedAndRegionManagerPropertyCleared_ThenItCanBeAddedAgainToARegion()
{
ContainerLocator.SetContainerExtension(Mock.Of());
- IRegion region = new Region { RegionManager = new MockRegionManager() };
+ IRegion region = new Region(new ContentControl()) { RegionManager = new MockRegionManager() };
var view = new MockFrameworkElement();
diff --git a/tests/Wpf/Prism.Wpf.Tests/Regions/RegionManagerFixture.cs b/tests/Wpf/Prism.Wpf.Tests/Regions/RegionManagerFixture.cs
index 32aacd63bb..e6ec5abe98 100644
--- a/tests/Wpf/Prism.Wpf.Tests/Regions/RegionManagerFixture.cs
+++ b/tests/Wpf/Prism.Wpf.Tests/Regions/RegionManagerFixture.cs
@@ -237,8 +237,8 @@ public void WhenAddingRegions_ThenRegionsCollectionNotifiesUpdate()
ContainerLocator.SetContainerExtension(Mock.Of());
var regionManager = new RegionManager();
- var region1 = new Region { Name = "region1" };
- var region2 = new Region { Name = "region2" };
+ var region1 = new Region(new ContentControl()) { Name = "region1" };
+ var region2 = new Region(new ContentControl()) { Name = "region2" };
NotifyCollectionChangedEventArgs args = null;
regionManager.Regions.CollectionChanged += (s, e) => args = e;
@@ -266,8 +266,8 @@ public void WhenRemovingRegions_ThenRegionsCollectionNotifiesUpdate()
ContainerLocator.SetContainerExtension(Mock.Of());
var regionManager = new RegionManager();
- var region1 = new Region { Name = "region1" };
- var region2 = new Region { Name = "region2" };
+ var region1 = new Region(new ContentControl()) { Name = "region1" };
+ var region2 = new Region(new ContentControl()) { Name = "region2" };
regionManager.Regions.Add(region1);
regionManager.Regions.Add(region2);
@@ -298,7 +298,7 @@ public void WhenRemovingNonExistingRegion_ThenRegionsCollectionDoesNotNotifyUpda
ContainerLocator.SetContainerExtension(Mock.Of());
var regionManager = new RegionManager();
- var region1 = new Region { Name = "region1" };
+ var region1 = new Region(new ContentControl()) { Name = "region1" };
regionManager.Regions.Add(region1);
diff --git a/tests/Wpf/Prism.Wpf.Tests/Regions/RegionNavigationServiceFixture.new.cs b/tests/Wpf/Prism.Wpf.Tests/Regions/RegionNavigationServiceFixture.new.cs
index f86ce03a98..54ba1c8e11 100644
--- a/tests/Wpf/Prism.Wpf.Tests/Regions/RegionNavigationServiceFixture.new.cs
+++ b/tests/Wpf/Prism.Wpf.Tests/Regions/RegionNavigationServiceFixture.new.cs
@@ -19,7 +19,7 @@ public void WhenNavigating_ViewIsActivated()
object view = new object();
Uri viewUri = new Uri(view.GetType().Name, UriKind.Relative);
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
region.Add(view);
string regionName = "RegionName";
@@ -55,7 +55,7 @@ public void WhenNavigatingWithQueryString_ViewIsActivated()
object view = new object();
Uri viewUri = new Uri(view.GetType().Name + "?MyQuery=true", UriKind.Relative);
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
region.Add(view);
string regionName = "RegionName";
@@ -91,7 +91,7 @@ public void WhenNavigatingAndViewCannotBeAcquired_ThenNavigationResultHasError()
object view = new object();
Uri viewUri = new Uri(view.GetType().Name, UriKind.Relative);
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
region.Add(view);
string otherType = "OtherType";
@@ -129,7 +129,7 @@ public void WhenNavigatingAndViewCannotBeAcquired_ThenNavigationResultHasError()
public void WhenNavigatingWithNullUri_Throws()
{
// Prepare
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
var containerMock = new Mock();
containerMock.Setup(x => x.Resolve(typeof(IRegionNavigationJournalEntry))).Returns(new RegionNavigationJournalEntry());
@@ -157,7 +157,7 @@ public void WhenNavigatingWithNullUri_Throws()
public void WhenNavigatingAndViewImplementsINavigationAware_ThenNavigatedIsInvokedOnNavigation()
{
// Prepare
- var region = new Region();
+ var region = new Region(new ContentControl());
var viewMock = new Mock();
viewMock.Setup(ina => ina.IsNavigationTarget(It.IsAny())).Returns(true);
@@ -189,7 +189,7 @@ public void WhenNavigatingAndViewImplementsINavigationAware_ThenNavigatedIsInvok
public void WhenNavigatingAndDataContextImplementsINavigationAware_ThenNavigatedIsInvokesOnNavigation()
{
// Prepare
- var region = new Region();
+ var region = new Region(new ContentControl());
Mock mockFrameworkElement = new Mock();
Mock mockINavigationAwareDataContext = new Mock();
@@ -224,7 +224,7 @@ public void WhenNavigatingAndDataContextImplementsINavigationAware_ThenNavigated
public void WhenNavigatingAndBothViewAndDataContextImplementINavigationAware_ThenNavigatedIsInvokesOnNavigation()
{
// Prepare
- var region = new Region();
+ var region = new Region(new ContentControl());
Mock mockFrameworkElement = new Mock();
Mock mockINavigationAwareView = mockFrameworkElement.As();
@@ -266,7 +266,7 @@ public void WhenNavigating_NavigationIsRecordedInJournal()
object view = new object();
Uri viewUri = new Uri(view.GetType().Name, UriKind.Relative);
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
region.Add(view);
string regionName = "RegionName";
@@ -306,7 +306,7 @@ public void WhenNavigating_NavigationIsRecordedInJournal()
public void WhenNavigatingAndCurrentlyActiveViewImplementsINavigateWithVeto_ThenNavigationRequestQueriesForVeto()
{
// Prepare
- var region = new Region();
+ var region = new Region(new ContentControl());
var viewMock = new Mock();
viewMock
@@ -342,7 +342,7 @@ public void WhenNavigatingAndCurrentlyActiveViewImplementsINavigateWithVeto_Then
public void WhenNavigating_ThenNavigationRequestQueriesForVetoOnAllActiveViewsIfAllSucceed()
{
// Prepare
- var region = new Region();
+ var region = new Region(new ContentControl());
var view1Mock = new Mock();
view1Mock
@@ -403,7 +403,7 @@ public void WhenNavigating_ThenNavigationRequestQueriesForVetoOnAllActiveViewsIf
public void WhenRequestNavigateAwayAcceptsThroughCallback_ThenNavigationProceeds()
{
// Prepare
- var region = new Region();
+ var region = new Region(new ContentControl());
var view1Mock = new Mock();
view1Mock
@@ -448,7 +448,7 @@ public void WhenRequestNavigateAwayAcceptsThroughCallback_ThenNavigationProceeds
public void WhenRequestNavigateAwayRejectsThroughCallback_ThenNavigationDoesNotProceed()
{
// Prepare
- var region = new Region();
+ var region = new Region(new ContentControl());
var view1Mock = new Mock();
view1Mock
@@ -493,7 +493,7 @@ public void WhenRequestNavigateAwayRejectsThroughCallback_ThenNavigationDoesNotP
public void WhenNavigatingAndDataContextOnCurrentlyActiveViewImplementsINavigateWithVeto_ThenNavigationRequestQueriesForVeto()
{
// Prepare
- var region = new Region();
+ var region = new Region(new ContentControl());
var viewModelMock = new Mock();
viewModelMock
@@ -533,7 +533,7 @@ public void WhenNavigatingAndDataContextOnCurrentlyActiveViewImplementsINavigate
public void WhenRequestNavigateAwayOnDataContextAcceptsThroughCallback_ThenNavigationProceeds()
{
// Prepare
- var region = new Region();
+ var region = new Region(new ContentControl());
var view1DataContextMock = new Mock();
view1DataContextMock
@@ -580,7 +580,7 @@ public void WhenRequestNavigateAwayOnDataContextAcceptsThroughCallback_ThenNavig
public void WhenRequestNavigateAwayOnDataContextRejectsThroughCallback_ThenNavigationDoesNotProceed()
{
// Prepare
- var region = new Region();
+ var region = new Region(new ContentControl());
var view1DataContextMock = new Mock();
view1DataContextMock
@@ -626,7 +626,7 @@ public void WhenRequestNavigateAwayOnDataContextRejectsThroughCallback_ThenNavig
[Fact]
public void WhenViewAcceptsNavigationOutAfterNewIncomingRequestIsReceived_ThenOriginalRequestIsIgnored()
{
- var region = new Region();
+ var region = new Region(new ContentControl());
var viewMock = new Mock();
var view = viewMock.Object;
@@ -678,7 +678,7 @@ public void WhenViewAcceptsNavigationOutAfterNewIncomingRequestIsReceived_ThenOr
[StaFact]
public void WhenViewModelAcceptsNavigationOutAfterNewIncomingRequestIsReceived_ThenOriginalRequestIsIgnored()
{
- var region = new Region();
+ var region = new Region(new ContentControl());
var viewModelMock = new Mock();
@@ -738,7 +738,7 @@ public void BeforeNavigating_NavigatingEventIsRaised()
object view = new object();
Uri viewUri = new Uri(view.GetType().Name, UriKind.Relative);
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
region.Add(view);
string regionName = "RegionName";
@@ -782,7 +782,7 @@ public void WhenNavigationSucceeds_NavigatedIsRaised()
object view = new object();
Uri viewUri = new Uri(view.GetType().Name, UriKind.Relative);
- IRegion region = new Region();
+ IRegion region = new Region(new ContentControl());
region.Add(view);
string regionName = "RegionName";
@@ -838,7 +838,7 @@ public void WhenTargetViewCreationThrowsWithAsyncConfirmation_ThenExceptionIsPro
.Setup(v => v.ConfirmNavigationRequest(It.IsAny(), It.IsAny>()))
.Callback>((nc, c) => { navigationCallback = c; });
- var region = new Region();
+ var region = new Region(new ContentControl());
region.Add(viewMock.Object);
region.Activate(viewMock.Object);
@@ -859,7 +859,7 @@ public void WhenTargetViewCreationThrowsWithAsyncConfirmation_ThenExceptionIsPro
public void WhenNavigatingFromViewThatIsNavigationAware_ThenNotifiesActiveViewNavigatingFrom()
{
// Arrange
- var region = new Region();
+ var region = new Region(new ContentControl());
var viewMock = new Mock();
var view = viewMock.Object;
region.Add(view);
@@ -896,7 +896,7 @@ public void WhenNavigationFromViewThatIsNavigationAware_OnlyNotifiesOnNavigateFr
bool navigationFromInvoked = false;
- var region = new Region();
+ var region = new Region(new ContentControl());
var viewMock = new Mock();
viewMock
@@ -936,7 +936,7 @@ public void WhenNavigationFromViewThatIsNavigationAware_OnlyNotifiesOnNavigateFr
public void WhenNavigatingFromActiveViewWithNavigatinAwareDataConext_NotifiesContextOfNavigatingFrom()
{
// Arrange
- var region = new Region();
+ var region = new Region(new ContentControl());
var mockDataContext = new Mock();
@@ -974,7 +974,7 @@ public void WhenNavigatingFromActiveViewWithNavigatinAwareDataConext_NotifiesCon
[Fact]
public void WhenNavigatingWithNullCallback_ThenThrows()
{
- var region = new Region();
+ var region = new Region(new ContentControl());
var navigationUri = new Uri("/", UriKind.Relative);
IContainerExtension container = new Mock().Object;
@@ -1019,7 +1019,7 @@ public void WhenNavigatingWithNullUri_ThenMarshallExceptionToCallback()
RegionNavigationService target = new RegionNavigationService(container, contentLoader, journal)
{
- Region = new Region()
+ Region = new Region(new ContentControl())
};
Exception error = null;
@@ -1034,7 +1034,7 @@ public void WhenNavigatingWithNullUri_ThenMarshallExceptionToCallback()
public void WhenNavigationFailsBecauseTheContentViewCannotBeRetrieved_ThenNavigationFailedIsRaised()
{
// Prepare
- var region = new Region { Name = "RegionName" };
+ var region = new Region(new ContentControl()) { Name = "RegionName" };
var containerMock = new Mock();
containerMock.Setup(x => x.Resolve(typeof(IRegionNavigationJournalEntry))).Returns(new RegionNavigationJournalEntry());
@@ -1076,7 +1076,7 @@ public void WhenNavigationFailsBecauseTheContentViewCannotBeRetrieved_ThenNaviga
public void WhenNavigationFailsBecauseActiveViewRejectsIt_ThenNavigationFailedIsRaised()
{
// Prepare
- var region = new Region { Name = "RegionName" };
+ var region = new Region(new ContentControl()) { Name = "RegionName" };
var view1Mock = new Mock();
view1Mock
@@ -1136,7 +1136,7 @@ public void WhenNavigationFailsBecauseActiveViewRejectsIt_ThenNavigationFailedIs
public void WhenNavigationFailsBecauseDataContextForActiveViewRejectsIt_ThenNavigationFailedIsRaised()
{
// Prepare
- var region = new Region { Name = "RegionName" };
+ var region = new Region(new ContentControl()) { Name = "RegionName" };
var viewModel1Mock = new Mock();
viewModel1Mock
diff --git a/tests/Wpf/Prism.Wpf.Tests/Regions/SelectorRegionAdapterFixture.cs b/tests/Wpf/Prism.Wpf.Tests/Regions/SelectorRegionAdapterFixture.cs
index b494b5750a..bc89210162 100644
--- a/tests/Wpf/Prism.Wpf.Tests/Regions/SelectorRegionAdapterFixture.cs
+++ b/tests/Wpf/Prism.Wpf.Tests/Regions/SelectorRegionAdapterFixture.cs
@@ -108,9 +108,9 @@ public TestableSelectorRegionAdapter()
}
- protected override IRegion CreateRegion()
+ protected override IRegion CreateRegion(object regionTarget)
{
- return new Region();
+ return new Region(regionTarget);
}
}
}
diff --git a/tests/Wpf/Prism.Wpf.Tests/Regions/SingleActiveRegionFixture.cs b/tests/Wpf/Prism.Wpf.Tests/Regions/SingleActiveRegionFixture.cs
index 6850578d37..fb0b8db80e 100644
--- a/tests/Wpf/Prism.Wpf.Tests/Regions/SingleActiveRegionFixture.cs
+++ b/tests/Wpf/Prism.Wpf.Tests/Regions/SingleActiveRegionFixture.cs
@@ -11,7 +11,7 @@ public class SingleActiveRegionFixture
public void ActivatingNewViewDeactivatesCurrent()
{
ContainerLocator.SetContainerExtension(Mock.Of());
- IRegion region = new SingleActiveRegion();
+ IRegion region = new SingleActiveRegion(new ContentControl());
var view = new object();
region.Add(view);
region.Activate(view);