/// <summary>
        /// Creates or identifies the element that is used to display the given item.
        /// </summary>
        /// <param name="item">The item to get the container for.</param>
        /// <param name="itemCollection">The parent's <see cref="ItemCollection"/>.</param>
        /// <returns>The element that is used to display the given item.</returns>
        protected virtual RadTabItem GetContainerForItem(object item, ItemCollection itemCollection)
        {
            if (itemCollection == null)
            {
                throw new ArgumentNullException("itemCollection");
            }
            RadTabItem container = item as RadTabItem;

            if (container != null && ((bool)container.GetValue(IsGeneratedProperty)) == false)
            {
                return(container);
            }

            foreach (RadTabItem tabItem in itemCollection)
            {
                if ((bool)tabItem.GetValue(IsGeneratedProperty))
                {
                    if (tabItem.Content == item)
                    {
                        return(tabItem);
                    }
                }
            }

            return(null);
        }
		/// <summary> 
		/// Gets the item contained in the <see cref="RadTabItem"/>. 
		/// </summary> 
		/// <param name="tabItem">The container item.</param> 
		/// <returns>The item contained in the <paramref name="tabItem"/> if it was generated automatically by the behavior; otherwise <paramref name="tabItem"/>.</returns> 
		protected virtual object GetContainedItem(RadTabItem tabItem)
		{
			if (tabItem == null) throw new ArgumentNullException("tabItem");
			if ((bool)tabItem.GetValue(IsGeneratedProperty))
			{
				return tabItem.Content;
			}

			return tabItem;
		}
 /// <summary>
 /// Undoes the effects of the <see cref="PrepareContainerForItem"/> method.
 /// </summary>
 /// <param name="tabItem">The container element for the item.</param>
 protected virtual void ClearContainerForItem(RadTabItem tabItem)
 {
     if (tabItem == null)
     {
         throw new ArgumentNullException("tabItem");
     }
     if (( bool )tabItem.GetValue(IsGeneratedProperty))
     {
         tabItem.Content = null;
     }
 }
        /// <summary>
        /// Gets the item contained in the <see cref="RadTabItem"/>.
        /// </summary>
        /// <param name="tabItem">The container item.</param>
        /// <returns>The item contained in the <paramref name="tabItem"/> if it was generated automatically by the behavior; otherwise <paramref name="tabItem"/>.</returns>
        protected virtual object GetContainedItem(RadTabItem tabItem)
        {
            if (tabItem == null)
            {
                throw new ArgumentNullException("tabItem");
            }
            if (( bool )tabItem.GetValue(IsGeneratedProperty))
            {
                return(tabItem.Content);
            }

            return(tabItem);
        }
		/// <summary> 
		/// Undoes the effects of the <see cref="PrepareContainerForItem"/> method. 
		/// </summary> 
		/// <param name="tabItem">The container element for the item.</param> 
		protected virtual void ClearContainerForItem(RadTabItem tabItem)
		{
			if (tabItem == null) throw new ArgumentNullException("tabItem");
			if ((bool)tabItem.GetValue(IsGeneratedProperty))
			{
				tabItem.Content = null;
			}
		}