Exemplo n.º 1
0
        private static void OnPopupContentChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
        {
            UIElement element = o as UIElement;

            if (element == null)
            {
                throw new InvalidOperationException("Can't hook to events other than UI Element");
            }

            if (e.NewValue != null)
            {
                RichToolTip popup = e.NewValue as RichToolTip;

                if (popup != null)
                {
                    popup.Load(element);
                }
                else
                {
                    popup = new RichToolTip(element);

                    Binding binding = new Binding
                    {
                        Path   = new PropertyPath(PopupContentProperty),
                        Mode   = BindingMode.OneWay,
                        Source = o,
                    };
                    popup.SetBinding(ContentProperty, binding);
                }

                SetContentTooltipWrapper(o, popup);
            }
        }