Microsoft.Practices.Prism.Regions.Behaviors.BindRegionContextToDependencyObjectBehavior.Attach C# (CSharp) Method

Attach() public method

Attaches the behavior to the specified region.
public Attach ( ) : void
return void
        public void Attach()
        {
            this.Region.Views.CollectionChanged += this.Views_CollectionChanged;
            this.Region.PropertyChanged += this.Region_PropertyChanged;
            SetContextToViews(this.Region.Views, this.Region.Context);
            this.AttachNotifyChangeEvent(this.Region.Views);
        }

Usage Example

        public void ShouldRemoveContextToViewRemovedFromRegion()
        {
            var behavior = new BindRegionContextToDependencyObjectBehavior();
            var region = new MockPresentationRegion();
            var view = new MockDependencyObject();
            region.Add(view);
            behavior.Region = region;
            region.Context = "MyContext";
            behavior.Attach();

            region.Remove(view);

            var context = RegionContext.GetObservableContext(view);
            Assert.IsNull(context.Value);
        }
All Usage Examples Of Microsoft.Practices.Prism.Regions.Behaviors.BindRegionContextToDependencyObjectBehavior::Attach