private void Window_Loaded(object sender, RoutedEventArgs e) { if (_lightBoxKind == CommonLightBoxKind.SaveCancel) { Grid.SetRowSpan(this.UpperBorder, 1); Grid.SetRow(this.LowerBorder, 1); Grid.SetRowSpan(this.LowerBorder, 2); this.UpperBorder.Visibility = System.Windows.Visibility.Visible; } else if (_lightBoxKind == CommonLightBoxKind.SaveOnly) { Grid.SetRow(this.UpperBorder, 0); Grid.SetRowSpan(this.UpperBorder, 3); Grid.SetRow(this.LowerBorder, 0); Grid.SetRowSpan(this.LowerBorder, 1); this.LowerBorder.Visibility = System.Windows.Visibility.Hidden; this.UpperBorder.Style = BaseGrid.FindResource("SaveBlackoutBorder") as Style; this.UpperBorderTextBlock.Style = BaseGrid.FindResource("SaveTextBlockStyle") as Style; } else if (_lightBoxKind == CommonLightBoxKind.CancelOnly) { Grid.SetRow(this.UpperBorder, 0); Grid.SetRowSpan(this.UpperBorder, 3); Grid.SetRow(this.LowerBorder, 0); Grid.SetRowSpan(this.LowerBorder, 1); this.LowerBorder.Visibility = System.Windows.Visibility.Hidden; this.UpperBorder.Style = BaseGrid.FindResource("CancelBlackoutBorder") as Style; this.UpperBorderTextBlock.Style = BaseGrid.FindResource("CancelTextBlockStyle") as Style; } if (Owner.WindowState == System.Windows.WindowState.Maximized) { var rect = GetWindowRectangle(Owner); this.Left = rect.Left; this.Top = rect.Top; } else { this.Left = Owner.Left; this.Top = Owner.Top; } if (!_isStretchable) { BaseGrid.RowDefinitions[0].Height = new GridLength(20); BaseGrid.RowDefinitions[1].Height = new GridLength(1.0, GridUnitType.Star); BaseGrid.RowDefinitions[2].Height = new GridLength(20); } this.ScrollViewer.HorizontalScrollBarVisibility = this.HorizontalScrollBarVisibility; this.ScrollViewer.VerticalScrollBarVisibility = this.VerticalScrollBarVisibility; this.Width = Owner.ActualWidth; this.Height = Owner.ActualHeight; this.TargetGrid.MaxWidth = Math.Max(this.Width - (BaseGrid.ColumnDefinitions[0].MinWidth + BaseGrid.ColumnDefinitions[2].MinWidth), 0); this.TargetGrid.MaxHeight = Math.Max(this.Height - (BaseGrid.RowDefinitions[0].MinHeight + BaseGrid.RowDefinitions[2].MinHeight), 0); }