private static void FrameworkElementGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
        {
            var frameworkElement = sender as FrameworkElement;

            if (frameworkElement != null)
            {
                if (_popupCalControl == null)
                {
                    _popupCalControl = new CalandarPopupControl();

                    _popupCalControl.AddHandler(UIElement.LostKeyboardFocusEvent,
                                                new KeyboardFocusChangedEventHandler(PopupCalendarLostKeyboardFocus));
                }

                _popupCalControl.TargetTextBox = GetTargetTextBox(frameworkElement);
                _popupCalControl.IsOpen        = true;
            }
        }
        private static void OnPlacementTargetChanged(DependencyObject element, DependencyPropertyChangedEventArgs e)
        {
            var frameworkElement = element as FrameworkElement;

            if (_popupCalControl == null)
            {
                _popupCalControl = new CalandarPopupControl();

                _popupCalControl.AddHandler(UIElement.LostKeyboardFocusEvent,
                                            new KeyboardFocusChangedEventHandler(PopupCalendarLostKeyboardFocus));
            }
            if (frameworkElement != null &&
                _popupCalControl != null)
            {
                _popupCalControl.TargetTextBox = GetTargetTextBox(frameworkElement);
                frameworkElement.AddHandler(UIElement.GotKeyboardFocusEvent,
                                            new KeyboardFocusChangedEventHandler(FrameworkElementGotKeyboardFocus),
                                            true);
                frameworkElement.AddHandler(UIElement.LostKeyboardFocusEvent,
                                            new KeyboardFocusChangedEventHandler(FrameworkElementLostKeyboardFocus));
            }
        }