public BalloonTip(UIElement ownerControl) { InitializeComponent(); OwnerControl = ownerControl; _ownerControlRect = new Rect(ownerControl.PointToScreen(new Point(0, 0)), ownerControl.RenderSize); _showTimer = new DispatcherTimer(); _showTimer.Interval = ShowDelay; _showTimer.Tick += _showTimer_Tick; _hideTimer = new DispatcherTimer(); _hideTimer.Interval = HideDelay; _hideTimer.Tick += _hideTimer_Tick; BalloonTip prevTip = GetBalloonTip(ownerControl); if (prevTip != null) { if (prevTip.IsOpen) { prevTip.FastClose(); } else if (prevTip._showTimer != null) { prevTip._showTimer.Stop(); prevTip._showTimer.Tick -= prevTip._showTimer_Tick; prevTip._showTimer = null; } } SetBalloonTip(ownerControl, this); }
protected static void SetBalloonTip(UIElement element, BalloonTip tip) { element.SetValue(BalloonTipProperty, tip); }