Browse Source

ChildWindow: fixed tabbing bug.

pull/1645/head
brianlagunas_cp 15 years ago
parent
commit
a1c5cee93b
  1. 67
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ChildWindow/ChildWindow.cs
  2. 22
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Themes/Generic.xaml

67
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)
{

22
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Themes/Generic.xaml

@ -455,7 +455,7 @@
<GradientStop Color="#7FFFFFFF" Offset="0.05"/>
<GradientStop Color="#B2FFFFFF" Offset="0.07"/>
<GradientStop Color="#00FFFFFF" Offset="1"/>
</LinearGradientBrush>
</LinearGradientBrush>
<Style TargetType="{x:Type local:ChildWindow}">
<Setter Property="Background" Value="#FFFFFFFF"/>
@ -463,10 +463,10 @@
<Setter Property="BorderThickness" Value="1" />
<Setter Property="CaptionForeground" Value="#FF000000" />
<Setter Property="CloseButtonStyle" Value="{StaticResource WindowCloseButtonStyle}" />
<Setter Property="Focusable" Value="False" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="IsEnabled" Value="true" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="OverlayBrush" Value="#7F000000" />
<Setter Property="OverlayOpacity" Value="1" />
<Setter Property="VerticalAlignment" Value="Top" />
@ -480,6 +480,22 @@
<Grid x:Name="Root">
<Grid.Resources>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<Style x:Key="FocusVisualStyle" TargetType="Control">
<Setter Property="BorderBrush" Value="Black"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Margin" Value="-1"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Rectangle Stroke="{TemplateBinding BorderBrush}" Fill="{TemplateBinding Background}" Margin="{TemplateBinding Margin}" StrokeDashArray="4 3" StrokeThickness="0.5">
<Rectangle.RenderTransform>
<TranslateTransform X="{Binding Left}" Y="{Binding Top}"/>
</Rectangle.RenderTransform>
</Rectangle>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>
<!--VisualStateManager-->
@ -510,7 +526,7 @@
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid x:Name="PART_WindowRoot" HorizontalAlignment="Left" VerticalAlignment="Top" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
<Grid x:Name="PART_WindowRoot" HorizontalAlignment="Left" VerticalAlignment="Top" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" >
<Grid.RenderTransform>
<TransformGroup>
<ScaleTransform />

Loading…
Cancel
Save