Ejemplo n.º 1
0
        /// <summary>
        /// Handles the property changed event of the ToolTip property.
        /// </summary>
        /// <param name="sender">Object whose value got changed.</param>
        /// <param name="args">Event args containing instance data.</param>
        private static void OnToolTipChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            BaseLabel label = sender as BaseLabel;

            if (label != null)
            {
                ToolTipService.SetToolTip(label, args.NewValue);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles the property changed event of the DisplayValue property.
        /// </summary>
        /// <param name="sender">Object whose value got changed.</param>
        /// <param name="args">Event args containing instance data.</param>
        private static void OnDisplayValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            BaseLabel label = sender as BaseLabel;

            if (label != null)
            {
                if (args.Property == DisplayValueProperty && !label.CanChangeDisplayValue)
                {
                    label.CanChangeDisplayValue = true;
                    label.DisplayValue          = args.OldValue as string;
                    label.CanChangeDisplayValue = false;
                    throw new InvalidOperationException("DisplayValue property is readonly.");
                }

                if (string.IsNullOrEmpty(label.DisplayValue))
                {
                    label.Visibility = Visibility.Collapsed;
                }
                else
                {
                    label.Visibility = Visibility.Visible;
                }
            }
        }