private static SizeChangedEventHandler SetupAndOpenDialog(MetroWindow window, BaseMetroDialog dialog) { dialog.SetValue(Panel.ZIndexProperty, (int)window.overlayBox.GetValue(Panel.ZIndexProperty) + 1); dialog.MinHeight = window.ActualHeight / 4; dialog.MaxHeight = window.ActualHeight; SizeChangedEventHandler minHeight = (object sender, SizeChangedEventArgs e) => { dialog.MinHeight = window.ActualHeight / 4; dialog.MaxHeight = window.ActualHeight; }; window.SizeChanged += minHeight; window.AddDialog(dialog); dialog.OnShown(); return(minHeight); }
private static SizeChangedEventHandler SetupAndOpenDialog(MetroWindow window, BaseMetroDialog dialog) { dialog.SetValue(Panel.ZIndexProperty, (int)window.overlayBox.GetValue(Panel.ZIndexProperty) + 1); dialog.MinHeight = window.ActualHeight / 4.0; dialog.MaxHeight = window.ActualHeight; SizeChangedEventHandler sizeHandler = (sender, args) => { dialog.MinHeight = window.ActualHeight / 4.0; dialog.MaxHeight = window.ActualHeight; }; window.SizeChanged += sizeHandler; window.AddDialog(dialog); dialog.OnShown(); return(sizeHandler); }
private static SizeChangedEventHandler SetupAndOpenDialog(MetroWindow window, BaseMetroDialog dialog) { dialog.SetValue(Panel.ZIndexProperty, (int)(window.overlayBox?.GetValue(Panel.ZIndexProperty) ?? 0) + 1); var fixedMinHeight = dialog.MinHeight > 0; var fixedMaxHeight = dialog.MaxHeight is not double.PositiveInfinity && dialog.MaxHeight > 0; void CalculateMinAndMaxHeight() { if (!fixedMinHeight) { dialog.SetCurrentValue(FrameworkElement.MinHeightProperty, window.ActualHeight / 4.0); } if (!fixedMaxHeight) { dialog.SetCurrentValue(FrameworkElement.MaxHeightProperty, window.ActualHeight); } else { dialog.SetCurrentValue(FrameworkElement.MinHeightProperty, Math.Min(dialog.MinHeight, dialog.MaxHeight)); } } CalculateMinAndMaxHeight(); void OnWindowSizeChanged(object sender, SizeChangedEventArgs args) { CalculateMinAndMaxHeight(); } window.SizeChanged += OnWindowSizeChanged; window.AddDialog(dialog); dialog.OnShown(); return(OnWindowSizeChanged); }