Class RegionManager
This class is responsible for maintaining a collection of regions and attaching regions to controls.
Implements
Namespace: Sartorius.SAF.Presentation.Regions
Assembly: Sartorius.SAF.Presentation.dll
Syntax
public class RegionManager : IRegionManager
Remarks
This class supplies the attached properties that can be used for simple region creation from XAML.
Constructors
View SourceRegionManager()
Initializes a new instance of RegionManager.
Declaration
public RegionManager()
Fields
View SourceRegionContextProperty
Identifies the RegionContext attached property.
Declaration
public static readonly DependencyProperty RegionContextProperty
Field Value
Type | Description |
---|---|
System.Windows.DependencyProperty |
RegionManagerProperty
Identifies the RegionManager attached property.
Declaration
public static readonly DependencyProperty RegionManagerProperty
Field Value
Type | Description |
---|---|
System.Windows.DependencyProperty |
Remarks
When a control has both the RegionNameProperty and RegionManagerProperty attached properties set to a value different than null and there is a IRegionAdapter mapping registered for the control, it will create and adapt a new region for that control, and register it in the IRegionManager with the specified region name.
RegionNameProperty
Identifies the RegionName attached property.
Declaration
public static readonly DependencyProperty RegionNameProperty
Field Value
Type | Description |
---|---|
System.Windows.DependencyProperty |
Remarks
When a control has both the RegionNameProperty and RegionManagerProperty attached properties set to a value different than null and there is a IRegionAdapter mapping registered for the control, it will create and adapt a new region for that control, and register it in the IRegionManager with the specified region name.
Properties
View SourceRegions
Gets a collection of IRegion that identify each region by name. You can use this collection to add or remove regions to the current region manager.
Declaration
public IRegionCollection Regions { get; }
Property Value
Type | Description |
---|---|
IRegionCollection | A IRegionCollection with all the registered regions. |
Methods
View SourceCreateRegionManager()
Creates a new region manager.
Declaration
public IRegionManager CreateRegionManager()
Returns
Type | Description |
---|---|
IRegionManager | A new region manager that can be used as a different scope from the current region manager. |
GetObservableRegion(DependencyObject)
Returns an ObservableObject<T> wrapper that can hold an IRegion. Using this wrapper you can detect when an IRegion has been created by the RegionAdapterBase<T>. If the ObservableObject<T> wrapper does not yet exist, a new wrapper will be created. When the region gets created and assigned to the wrapper, you can use the PropertyChanged event to get notified of that change.
Declaration
public static ObservableObject<IRegion> GetObservableRegion(DependencyObject view)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyObject | view | The view that will host the region. |
Returns
Type | Description |
---|---|
ObservableObject<IRegion> | Wrapper that can hold an IRegion value and can notify when the IRegion value changes. |
GetRegionContext(DependencyObject)
Gets the value of the RegionContextProperty attached property.
Declaration
public static object GetRegionContext(DependencyObject target)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyObject | target | The target element. |
Returns
Type | Description |
---|---|
System.Object | The region context to pass to the contained views. |
GetRegionManager(DependencyObject)
Gets the value of the RegionNameProperty attached property.
Declaration
public static IRegionManager GetRegionManager(DependencyObject target)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyObject | target | The target element. |
Returns
Type | Description |
---|---|
IRegionManager | The IRegionManager attached to the |
GetRegionName(DependencyObject)
Gets the value for the RegionNameProperty attached property.
Declaration
public static string GetRegionName(DependencyObject regionTarget)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyObject | regionTarget | The object to adapt. This is typically a container (i.e a control). |
Returns
Type | Description |
---|---|
System.String | The name of the region that should be created when RegionManagerProperty is also set in this element. |
SetRegionContext(DependencyObject, Object)
Sets the RegionContextProperty attached property.
Declaration
public static void SetRegionContext(DependencyObject target, object value)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyObject | target | The target element. |
System.Object | value | The value. |
SetRegionManager(DependencyObject, IRegionManager)
Sets the RegionManagerProperty attached property.
Declaration
public static void SetRegionManager(DependencyObject target, IRegionManager value)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyObject | target | The target element. |
IRegionManager | value | The value. |
SetRegionName(DependencyObject, String)
Sets the RegionNameProperty attached property.
Declaration
public static void SetRegionName(DependencyObject regionTarget, string regionName)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyObject | regionTarget | The object to adapt. This is typically a container (i.e a control). |
System.String | regionName | The name of the region to register. |
UpdateRegions()
Notifies attached behaviors to update the region managers appropriately if needed to.
Declaration
public static void UpdateRegions()
Remarks
This method is normally called internally, and there is usually no need to call this from user code.
Events
View SourceUpdatingRegions
Notification used by attached behaviors to update the region managers appropriatelly if needed to.
Declaration
public static event EventHandler UpdatingRegions
Event Type
Type | Description |
---|---|
System.EventHandler |
Remarks
This event uses weak references to the event handler to prevent this static event of keeping the target element longer than expected. For security reasons, to use weak delegates in Silverlight you must provide a delegate that is available in the public API of the class (no private or anonymous delegates allowed).