public void ShouldCreateWindowWrapperAndSetProperties() { var a = new WindowDialogActivationBehavior(); var windowWrapper = new WindowWrapper(); var style = new Style(); windowWrapper.Style = style; Assert.AreEqual(style, windowWrapper.Style); var content = new Grid(); windowWrapper.Content = content; Assert.AreEqual(content, windowWrapper.Content); var owner = new Window(); owner.Show(); windowWrapper.Owner = owner; Assert.AreEqual(owner, windowWrapper.Owner); windowWrapper.Show(); windowWrapper.Closed += WindowWrapperOnClosed; windowWrapper.Close(); windowWrapper.Closed -= WindowWrapperOnClosed; Assert.IsTrue(this._wasClosed); }
/// <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 = ContainerLocator.Container.Resolve <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); } }
/// <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; #if SILVERLIGHT behavior = new PopupDialogActivationBehavior(); #else behavior = new WindowDialogActivationBehavior(); #endif behavior.HostControl = owner; region.Behaviors.Add(DialogActivationBehavior.BehaviorKey, behavior); regionManager.Regions.Add(regionName, region); } }