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. RegionMngr = ServiceLocator.Current.GetAllInstances <IRegionManager>().First(); if (RegionMngr != 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); RegionMngr.Regions.Add(regionName, region); } }
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. RegionMngr = ServiceLocator.Current.GetAllInstances<IRegionManager>().First(); if (RegionMngr != 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); RegionMngr.Regions.Add(regionName, region); } }