Skip to content

Commit

Permalink
Merge pull request #2190 from cwensley/curtis/fix-wpf-richtextarea-au…
Browse files Browse the repository at this point in the history
…tosize-width

Wpf: RichTextArea should not auto size to width of constraints
  • Loading branch information
cwensley authored Apr 18, 2022
2 parents 54fd70c + 8a0aaf8 commit 38f1368
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/Eto.Wpf/Forms/Controls/TextAreaHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ public TextAreaHandler()
};
Wrap = true;
}

protected override void Initialize()
{
base.Initialize();
UserPreferredSize = DefaultSize; // otherwise it grows to the constraint, which we don't want.
}

public override sw.Size MeasureOverride(sw.Size constraint, Func<sw.Size, sw.Size> measure)
{
Expand Down
11 changes: 10 additions & 1 deletion test/Eto.Test/UnitTests/Forms/Controls/TextAreaTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class TextAreaTests : TextAreaTests<TextArea>
}

public class TextAreaTests<T> : TestBase
where T: TextArea, new()
where T : TextArea, new()
{
[Test]
public void CheckSelectionTextCaretAfterSettingText()
Expand Down Expand Up @@ -117,5 +117,14 @@ public void InitialValueOfSelectedTextShouldBeEmptyInsteadOfNull()
Assert.AreEqual(string.Empty, textArea.SelectedText, "SelectedText should *still* be empty not null after setting text");
});
}

[Test]
[ManualTest]
public void ScaledShouldNotGrowDialog() => Invoke(() =>
{
var dlg = new Dialog();
dlg.Content = new T() { Text = "Hello! The dialog should not grow too large or anything, and should make this text wrap." };
dlg.ShowModal();
}, -1);
}
}

0 comments on commit 38f1368

Please sign in to comment.