示例#1
0
        protected override RegionAdapterMappings ConfigureRegionAdapterMappings()
        {
            Application.Current.ShutdownMode = System.Windows.ShutdownMode.OnLastWindowClose;
            // create region
            var region = new SingleActiveRegion() { Name = RegionNames.MainRegion };

            region.Behaviors.Add(DragablzWindowBehavior.BehaviorKey, new DragablzWindowBehavior());

            Container.Resolve<RegionManager>().Regions.Add(RegionNames.MainRegion, region);

            return base.ConfigureRegionAdapterMappings();
        }
示例#2
0
 public static void RegisterNewExternalRegion(string regionName)
 {
     IRegionManager regionManager = ServiceLocator.Current.GetInstance<IRegionManager>();
     if (regionManager != null)
     {
         IRegion region = new SingleActiveRegion();
         ExternalRegionActivationBehavior behavior = new ExternalRegionActivationBehavior();
         //behavior.HostControl = owner;
         region.Behaviors.Add(ExternalRegionActivationBehavior.BehaviorKey, behavior);
         regionManager.Regions.Add(regionName, region);
     }
 }
        public void ActivatingNewViewDeactivatesCurrent()
        {
            IRegion region = new SingleActiveRegion();
            var view = new object();
            region.Add(view);
            region.Activate(view);

            Assert.IsTrue(region.ActiveViews.Contains(view));

            var view2 = new object();
            region.Add(view2);
            region.Activate(view2);

            Assert.IsFalse(region.ActiveViews.Contains(view));
            Assert.IsTrue(region.ActiveViews.Contains(view2));
        }
        public async Task ActivatingNewViewDeactivatesCurrent()
        {
            await ExecuteOnUIThread(() =>
                {
                    IRegion region = new SingleActiveRegion();
                    var view = new object();
                    region.Add(view);
                    region.Activate(view);

                    Assert.IsTrue(region.ActiveViews.Contains(view));

                    var view2 = new object();
                    region.Add(view2);
                    region.Activate(view2);

                    Assert.IsFalse(region.ActiveViews.Contains(view));
                    Assert.IsTrue(region.ActiveViews.Contains(view2));
                });
        }
示例#5
0
        /// <summary>
        /// Creates a new <see cref="IRegion"/> and registers it in the default <see cref="IRegionManager"/>
        /// attaching to it a <see cref="DialogActivationBehavior"/> behavior.
        /// </summary>
        /// <param name="owner">The owner of the Popup.</param>
        /// <param name="regionName">The name of the <see cref="IRegion"/>.</param>
        /// <remarks>
        /// This method would typically not be called directly, instead the behavior 
        /// should be set through the Attached Property <see cref="CreatePopupRegionWithNameProperty"/>.
        /// </remarks>
        public static void RegisterNewPopupRegion(DependencyObject owner, string regionName)
        {
            // Creates a new region and registers it in the default region manager.
            // Another option if you need the complete infrastructure with the default region behaviors
            // is to extend DelayedRegionCreationBehavior overriding the CreateRegion method and create an
            // instance of it that will be in charge of registering the Region once a RegionManager is
            // set as an attached property in the Visual Tree.
            IRegionManager regionManager = ServiceLocator.Current.GetInstance<IRegionManager>();
            if (regionManager != null)
            {
                IRegion region = new SingleActiveRegion();
                DialogActivationBehavior behavior;
                behavior = new WindowDialogActivationBehavior();
                behavior.HostControl = owner;

                region.Behaviors.Add(DialogActivationBehavior.BehaviorKey, behavior);
                regionManager.Regions.Add(regionName, region);
            }
        }