예제 #1
0
        public void ShouldCreateRegion()
        {
            try
            {
                var regionManager = new MockRegionManager();
                ServiceLocator.SetLocatorProvider(() => new MockServiceLocator(() => regionManager));

                FrameworkElement hostControl = new MockFrameworkElement();
                RegionPopupBehaviors.RegisterNewPopupRegion(hostControl, "MyPopupRegion");

                Assert.IsTrue(regionManager.MockRegions.Regions.ContainsKey("MyPopupRegion"));
                Assert.IsNotNull(regionManager.MockRegions.Regions["MyPopupRegion"]);
                Assert.IsInstanceOfType(regionManager.MockRegions.Regions["MyPopupRegion"], typeof(SingleActiveRegion));
                Assert.IsTrue(regionManager.MockRegions.Regions["MyPopupRegion"].Behaviors.ContainsKey(DialogActivationBehavior.BehaviorKey));
#if SILVERLIGHT
                Assert.IsInstanceOfType(regionManager.MockRegions.Regions["MyPopupRegion"].Behaviors[DialogActivationBehavior.BehaviorKey], typeof(PopupDialogActivationBehavior));
#else
                Assert.IsInstanceOfType(regionManager.MockRegions.Regions["MyPopupRegion"].Behaviors[DialogActivationBehavior.BehaviorKey], typeof(WindowDialogActivationBehavior));
#endif
            }
            finally
            {
                ServiceLocator.SetLocatorProvider(() => null);
            }
        }
예제 #2
0
        public void ShouldCreateRegion()
        {
            try
            {
                var regionManager = new MockRegionManager();
                ServiceLocator.SetLocatorProvider(() => new MockServiceLocator(() => regionManager));

                FrameworkElement hostControl = new MockFrameworkElement();
                RegionPopupBehaviors.RegisterNewPopupRegion(hostControl, "MyPopupRegion");
                RegionPopupBehaviors.SetCreatePopupRegionWithName(hostControl, "MyPopupRegion");
                Assert.AreEqual("MyPopupRegion", RegionPopupBehaviors.GetCreatePopupRegionWithName(hostControl));

                var style = new Style();
                RegionPopupBehaviors.SetContainerWindowStyle(hostControl, style);
                Assert.AreEqual(style, RegionPopupBehaviors.GetContainerWindowStyle(hostControl));

                Assert.IsTrue(regionManager.MockRegions.Regions.ContainsKey("MyPopupRegion"));
                Assert.IsNotNull(regionManager.MockRegions.Regions["MyPopupRegion"]);
                Assert.IsInstanceOfType(regionManager.MockRegions.Regions["MyPopupRegion"], typeof(SingleActiveRegion));
                Assert.IsTrue(regionManager.MockRegions.Regions["MyPopupRegion"].Behaviors.ContainsKey(DialogActivationBehavior.BehaviorKey));
                Assert.IsInstanceOfType(regionManager.MockRegions.Regions["MyPopupRegion"].Behaviors[DialogActivationBehavior.BehaviorKey], typeof(WindowDialogActivationBehavior));
            }
            finally
            {
                ServiceLocator.SetLocatorProvider(() => null);
            }
        }
예제 #3
0
        protected override Microsoft.Practices.Prism.Regions.RegionAdapterMappings ConfigureRegionAdapterMappings()
        {
            var baseMappings = base.ConfigureRegionAdapterMappings();

            baseMappings.RegisterMapping(typeof(System.Windows.Controls.Accordion), ServiceLocator.Current.GetInstance <AccordionRegionAdapter>());


            var windowStyle = (Style)Application.Current.FindResource("WindowRegionStyle");

            RegionPopupBehaviors.RegisterNewWindowRegion(RegionNames.WindowRegion, windowStyle);

            var popupStyle = (Style)Application.Current.FindResource("PopupRegionStyle");

            RegionPopupBehaviors.RegisterNewWindowRegion(RegionNames.PopupWindowRegion, popupStyle);

            return(baseMappings);
        }
예제 #4
0
 public void SetCreatePopupRegionWithNameShouldThrowExceptionWhenOwnerIsNull()
 {
     RegionPopupBehaviors.SetCreatePopupRegionWithName(null, "My Region");
 }
예제 #5
0
 public void SetContainerWindowStyleShouldThrowExceptionWhenOwnerIsNull()
 {
     RegionPopupBehaviors.SetContainerWindowStyle(null, new Style());
 }