The label to display on the InfoTextBox.
Inheritance: System.Windows.Documents.Adorner
示例#1
0
        /// <summary>Updates the adorner.</summary>
        /// <param name="element">The element.</param>
        /// <param name="hide">If set to <c>True</c> hide the adorner.</param>
        void UpdateAdorner(FrameworkElement element, bool hide = false)
        {
            if (element == null || myAdornerLayer == null)
            {
                return;
            }

            myAdornerLabel = new AdornerLabel(this, Note, NoteStyle);
            RemoveAdorners <AdornerLabel>(myAdornerLayer, element);

            if (!((InfoTextBox)element).HasText && !element.IsFocused && !hide)
            {
                myAdornerLayer.Add(myAdornerLabel);
            }
        }
示例#2
0
        /// <summary>Is called when a control template is applied.</summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            myAdornerLayer = AdornerLayer.GetAdornerLayer(this);
            myAdornerLabel = new AdornerLabel(this, Note, NoteStyle);
            UpdateAdorner(this);

            DependencyPropertyDescriptor focusProp = DependencyPropertyDescriptor.FromProperty(
                IsFocusedProperty, typeof(FrameworkElement));

            if (focusProp != null)
            {
                focusProp.AddValueChanged(this, delegate { UpdateAdorner(this); });
            }

            DependencyPropertyDescriptor containsTextProp = DependencyPropertyDescriptor.FromProperty(
                HasTextProperty, typeof(InfoTextBox));

            if (containsTextProp != null)
            {
                containsTextProp.AddValueChanged(this, delegate { UpdateAdorner(this); });
            }
        }