private static void OnOverlayBrushChanged(DependencyObject d,
                                              DependencyPropertyChangedEventArgs e)
    {
        ModalContentPresenter control = (ModalContentPresenter)d;

        control.overlay.Background = (Brush)e.NewValue;
    }
    private static void OnModalContentChanged(DependencyObject d,
                                              DependencyPropertyChangedEventArgs e)
    {
        ModalContentPresenter control = (ModalContentPresenter)d;

        if (e.OldValue != null)
        {
            control.RemoveLogicalChild(e.OldValue);
        }
        control.modalContent.Content = e.NewValue;
        control.AddLogicalChild(e.NewValue);
        control.logicalChildren[1] = e.NewValue;
    }
    private static void OnIsModalChanged(DependencyObject d,
                                         DependencyPropertyChangedEventArgs e)
    {
        ModalContentPresenter control = (ModalContentPresenter)d;

        if ((bool)e.NewValue == true)
        {
            control.cachedKeyboardNavigationMode =
                KeyboardNavigation.GetTabNavigation(control.primaryContent);
            KeyboardNavigation.SetTabNavigation(
                control.primaryContent, KeyboardNavigationMode.None);
            control.overlay.Visibility = Visibility.Visible;
            control.overlay.MoveFocus(traversalDirection);
            control.RaiseModalContentShownEvents();
        }
        else
        {
            control.overlay.Visibility = Visibility.Hidden;
            KeyboardNavigation.SetTabNavigation(
                control.primaryContent, control.cachedKeyboardNavigationMode);
            control.primaryContent.MoveFocus(traversalDirection);
            control.RaiseModalContentHiddenEvents();
        }
    }