diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ChildWindow/ChildWindow.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ChildWindow/ChildWindow.cs index 74b9842e..01b81462 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ChildWindow/ChildWindow.cs +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ChildWindow/ChildWindow.cs @@ -26,6 +26,9 @@ namespace Microsoft.Windows.Controls private Rectangle _modalLayer = new Rectangle(); private Canvas _modalLayerPanel = new Canvas(); + private const int _horizaontalOffset = 3; + private const int _verticalOffset = 3; + #endregion //Private Members #region Constructors @@ -63,10 +66,8 @@ namespace Microsoft.Windows.Controls //Overlay = GetTemplateChild("PART_Overlay") as Panel; WindowRoot = GetTemplateChild("PART_WindowRoot") as Grid; - WindowRoot.RenderTransform = _moveTransform; - _parentContainer = VisualTreeHelper.GetParent(this) as FrameworkElement; //this is for XBAP applications only. When inside an XBAP the parent container has no height or width until it has loaded. Therefore @@ -87,12 +88,50 @@ namespace Microsoft.Windows.Controls }; _root = GetTemplateChild("Root") as Grid; + + Style focusStyle = _root.Resources["FocusVisualStyle"] as Style; + if (focusStyle != null) + { + Setter focusStyleDataContext = new Setter(Control.DataContextProperty, this); + focusStyle.Setters.Add(focusStyleDataContext); + FocusVisualStyle = focusStyle; + } + _root.Children.Add(_modalLayerPanel); ChangeVisualState(); } + protected override void OnKeyDown(KeyEventArgs e) + { + base.OnKeyDown(e); + + if (WindowState == WindowState.Open) + { + switch (e.Key) + { + case Key.Left: + this.Left -= _horizaontalOffset; + e.Handled = true; + break; + + case Key.Right: + this.Left += _horizaontalOffset; + e.Handled = true; + break; + + case Key.Down: + this.Top += _verticalOffset; + e.Handled = true; + break; + case Key.Up: + this.Top -= _verticalOffset; + e.Handled = true; + break; + } + } + } #endregion //Base Class Overrides @@ -145,6 +184,8 @@ namespace Microsoft.Windows.Controls set { SetValue(IconSourceProperty, value); } } + #region IsModal + public static readonly DependencyProperty IsModalProperty = DependencyProperty.Register("IsModal", typeof(bool), typeof(ChildWindow), new UIPropertyMetadata(false, new PropertyChangedCallback(OnIsModalPropertyChanged))); public bool IsModal { @@ -155,12 +196,26 @@ namespace Microsoft.Windows.Controls private static void OnIsModalPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { ChildWindow childWindow = (ChildWindow)d; - if ((bool)e.NewValue) - childWindow.ShowModalLayer(); + if (childWindow != null) + childWindow.OnIsModalChanged((bool)e.OldValue, (bool)e.NewValue); + } + + private void OnIsModalChanged(bool oldValue, bool newValue) + { + if (newValue) + { + KeyboardNavigation.SetTabNavigation(this, KeyboardNavigationMode.Cycle); + ShowModalLayer(); + } else - childWindow.HideModalLayer(); + { + KeyboardNavigation.SetTabNavigation(this, KeyboardNavigationMode.Continue); + HideModalLayer(); + } } + #endregion //IsModal + #region Left public static readonly DependencyProperty LeftProperty = DependencyProperty.Register("Left", typeof(double), typeof(ChildWindow), new PropertyMetadata(0.0, new PropertyChangedCallback(OnLeftPropertyChanged))); @@ -362,7 +417,7 @@ namespace Microsoft.Windows.Controls private double GetRestrictedTop() { - if (_parentContainer != null ) + if (_parentContainer != null) { if (Top < 0) { diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Themes/Generic.xaml b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Themes/Generic.xaml index 166f4e6f..4f3f7a1a 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Themes/Generic.xaml +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Themes/Generic.xaml @@ -455,7 +455,7 @@ - + @@ -510,7 +526,7 @@ - +