Skip to content

Commit

Permalink
Fix #222: ContentDialog is not centered when MaxWidth/MaxHeight not set
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinnara committed Dec 17, 2020
1 parent 27c10fa commit d5d2266
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ModernWpf.Controls/ContentDialog/ContentDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1163,12 +1163,15 @@ protected override Visual GetVisualChild(int index)

protected override Size MeasureOverride(Size constraint)
{
var desiredSize = AdornedElement.RenderSize;
constraint = desiredSize;
Child?.Measure(constraint);
return constraint;
return desiredSize;
}

protected override Size ArrangeOverride(Size finalSize)
protected override Size ArrangeOverride(Size size)
{
var finalSize = base.ArrangeOverride(size);
Child?.Arrange(new Rect(new Point(), finalSize));
return finalSize;
}
Expand Down

0 comments on commit d5d2266

Please sign in to comment.