/// <summary>
        ///     Gives a string representation of this object.
        /// </summary>
        public override string ToString()
        {
            string typeText      = this.GetType().ToString();
            string headerText    = String.Empty;
            string contentText   = String.Empty;
            bool   valuesDefined = false;

            // Accessing Header's content may be thread sensitive
            if (CheckAccess())
            {
                headerText    = ContentControl.ContentObjectToString(Header);
                contentText   = ContentControl.ContentObjectToString(Content);
                valuesDefined = true;
            }
            else
            {
                //Not on dispatcher, try posting to the dispatcher with 20ms timeout
                Dispatcher.Invoke(DispatcherPriority.Send, new TimeSpan(0, 0, 0, 0, 20), new DispatcherOperationCallback(delegate(object o)
                {
                    headerText    = ContentControl.ContentObjectToString(Header);
                    contentText   = ContentControl.ContentObjectToString(Content);
                    valuesDefined = true;
                    return(null);
                }), null);
            }

            // If header and content text are defined
            if (valuesDefined)
            {
                return(SR.Get(SRID.ToStringFormatString_HeaderedContentControl, typeText, headerText, contentText));
            }

            // Not able to access the dispatcher
            return(typeText);
        }
Example #2
0
        /// <summary>Provides a string representation of a <see cref="T:System.Windows.Controls.HeaderedContentControl" />. </summary>
        /// <returns>A string representation of the object.</returns>
        // Token: 0x06004E44 RID: 20036 RVA: 0x00160524 File Offset: 0x0015E724
        public override string ToString()
        {
            string text          = base.GetType().ToString();
            string headerText    = string.Empty;
            string contentText   = string.Empty;
            bool   valuesDefined = false;

            if (base.CheckAccess())
            {
                headerText    = ContentControl.ContentObjectToString(this.Header);
                contentText   = ContentControl.ContentObjectToString(base.Content);
                valuesDefined = true;
            }
            else
            {
                base.Dispatcher.Invoke(DispatcherPriority.Send, new TimeSpan(0, 0, 0, 0, 20), new DispatcherOperationCallback(delegate(object o)
                {
                    headerText    = ContentControl.ContentObjectToString(this.Header);
                    contentText   = ContentControl.ContentObjectToString(this.Content);
                    valuesDefined = true;
                    return(null);
                }), null);
            }
            if (valuesDefined)
            {
                return(SR.Get("ToStringFormatString_HeaderedContentControl", new object[]
                {
                    text,
                    headerText,
                    contentText
                }));
            }
            return(text);
        }
Example #3
0
        /// <summary>
        ///     Gives a string representation of this object.
        /// </summary>
        public override string ToString()
        {
            string typeText      = this.GetType().ToString();
            string headerText    = String.Empty;
            int    itemCount     = 0;
            bool   valuesDefined = false;

            // Accessing Header's content may be thread sensitive
            if (CheckAccess())
            {
                headerText = ContentControl.ContentObjectToString(Header);
                // HasItems may be wrong when underlying collection does not notify,
                // but this function should try to return what's consistent with ItemsControl state.
                itemCount     = HasItems ? Items.Count : 0;
                valuesDefined = true;
            }
            else
            {
                //Not on dispatcher, try posting to the dispatcher with 20ms timeout
                Dispatcher.Invoke(DispatcherPriority.Send, new TimeSpan(0, 0, 0, 0, 20), new DispatcherOperationCallback(delegate(object o)
                {
                    headerText = ContentControl.ContentObjectToString(Header);
                    // HasItems may be wrong when underlying collection does not notify,
                    // but this function should try to return what's consistent with ItemsControl state.
                    itemCount     = HasItems ? Items.Count : 0;
                    valuesDefined = true;
                    return(null);
                }), null);
            }

            // If header and items count are defined
            if (valuesDefined)
            {
                return(SR.Get(SRID.ToStringFormatString_HeaderedItemsControl, typeText, headerText, itemCount));
            }

            // Not able to access the dispatcher
            return(typeText);
        }
 /// <summary>
 ///     Gives a string representation of this object.
 /// </summary>
 /// <returns></returns>
 internal override string GetPlainText()
 {
     return(ContentControl.ContentObjectToString(Header));
 }