Browse Source

ChildWindow: fixed modal overlay when IsModal = true

pull/1645/head
brianlagunas_cp 15 years ago
parent
commit
ea183afbc3
  1. 57
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ChildWindow/ChildWindow.cs

57
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ChildWindow/ChildWindow.cs

@ -150,18 +150,6 @@ namespace Microsoft.Windows.Controls
childWindow.HideModalLayer();
}
private void ShowModalLayer()
{
_modalLayerPanel.Children.Add(_modalLayer);
BringToFront();
}
private void HideModalLayer()
{
}
#region Left
public static readonly DependencyProperty LeftProperty = DependencyProperty.Register("Left", typeof(double), typeof(ChildWindow), new PropertyMetadata(0.0, new PropertyChangedCallback(OnLeftPropertyChanged)));
@ -419,32 +407,24 @@ namespace Microsoft.Windows.Controls
private void ExecuteOpen()
{
_dialogResult = null; //reset the dialogResult to null each time the window is opened
SetZIndex(); //TODO: replace with BringToFront
BringToFront();
}
private void SetZIndex()
private void BringToFront()
{
int index = 0;
if (_parentContainer != null)
{
int parentIndex = (int)_parentContainer.GetValue(Canvas.ZIndexProperty);
this.SetValue(Canvas.ZIndexProperty, ++parentIndex);
index = (int)_parentContainer.GetValue(Canvas.ZIndexProperty);
}
else
{
this.SetValue(Canvas.ZIndexProperty, 1);
}
}
private void BringToFront()
{
int zIndex = 0;
this.SetValue(Canvas.ZIndexProperty, 1);
Canvas.SetZIndex(this, zIndex += 99);
//if modal
this.SetValue(Canvas.ZIndexProperty, ++index);
if (IsModal)
{
Canvas.SetZIndex(_modalLayerPanel, -1);
}
}
private void SetStartupPosition()
@ -476,6 +456,23 @@ namespace Microsoft.Windows.Controls
}
}
private void ShowModalLayer()
{
if (!DesignerProperties.GetIsInDesignMode(this))
{
if (!_modalLayerPanel.Children.Contains(_modalLayer))
_modalLayerPanel.Children.Add(_modalLayer);
BringToFront();
}
}
private void HideModalLayer()
{
if (_modalLayerPanel.Children.Contains(_modalLayer))
_modalLayerPanel.Children.Remove(_modalLayer);
}
#endregion //Private
#region Protected

Loading…
Cancel
Save