//------------------------------------------------------------------- 
        //   Methods
        //-------------------------------------------------------------------

        #region Methods

        /// <summary>
        /// Retreives instance  of this class from attached object or creates new.
        /// </summary>
        /// <param name="parent"><see cref="TabControl"/> where we attaching to.</param>
        /// <returns>Returns instance of this class</returns>
        private static TabItemGeneratorBehavior GetHandler(TabControl parent)
        {
            var binding = parent.GetBindingExpression(TabControl.SelectedItemProperty);

            return (null == binding) ? new TabItemGeneratorBehavior(parent)
                                     : binding.DataItem as TabItemGeneratorBehavior;
        }