public void Detach()
 {
     if (DeviceTypeHelper.GetDeviceFormFactorType() == DeviceFormFactorType.Phone)
     {
         (AssociatedObject as Hub).SizeChanged -= HubSectionFillPageBehavior_SizeChanged;
         (AssociatedObject as Hub).Loaded      -= HubSectionFillPageBehavior_Loaded;
     }
     this.AssociatedObject = null;
 }
        public void Attach(DependencyObject associatedObject)
        {
            if (this.AssociatedObject != null)
            {
                throw new InvalidOperationException("Cannot assign to the same behavior twice.");
            }
            else if (associatedObject.GetType() != typeof(Hub))
            {
                throw new InvalidOperationException("Can only assign to Hub");
            }

            this.AssociatedObject = associatedObject;

            if (DeviceTypeHelper.GetDeviceFormFactorType() == DeviceFormFactorType.Phone)
            {
                (AssociatedObject as Hub).SizeChanged += HubSectionFillPageBehavior_SizeChanged;
                (AssociatedObject as Hub).Loaded      += HubSectionFillPageBehavior_Loaded;
            }
        }