Skip to content

Commit 6b5aaa6

Browse files
TextBox: Removed not needed VerticalAlignment and it now respects VerticalContentAlignment (#3162)
* Removed not needed VerticalAlignment * Add support for TextBox.VerticalContentAlignment * Added UI test for all VerticalAlignment scenarios * Fixed broken test PART_ContentHost now uses both VerticalAlignment and VerticalContentAlignment; the test now reflects that as well.
1 parent ceb3ebd commit 6b5aaa6

File tree

5 files changed

+213
-173
lines changed

5 files changed

+213
-173
lines changed

MaterialDesignThemes.UITests/WPF/TextBoxes/TextBoxTests.cs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ public async Task VerticalContentAlignment_ProperlyAlignsText()
391391
foreach (var alignment in Enum.GetValues<VerticalAlignment>())
392392
{
393393
await textBox.SetVerticalContentAlignment(alignment);
394-
Assert.Equal(alignment, await scrollViewer.GetVerticalAlignment());
394+
Assert.Equal(alignment, await scrollViewer.GetVerticalContentAlignment());
395395
}
396396

397397
recorder.Success();
@@ -562,6 +562,34 @@ public async Task TextBox_WithHintAndValidationError_RespectsPadding(string styl
562562

563563
recorder.Success();
564564
}
565+
566+
[Theory]
567+
[InlineData(VerticalAlignment.Stretch, VerticalAlignment.Top)]
568+
[InlineData(VerticalAlignment.Top, VerticalAlignment.Top)]
569+
[InlineData(VerticalAlignment.Bottom, VerticalAlignment.Bottom)]
570+
[InlineData(VerticalAlignment.Center, VerticalAlignment.Center)]
571+
[Description("Issue 3161")]
572+
public async Task TextBox_MultiLineAndFixedHeight_RespectsVerticalContentAlignment(VerticalAlignment alignment, VerticalAlignment expectedFloatingHintAlignment)
573+
{
574+
await using var recorder = new TestRecorder(App);
575+
576+
var stackPanel = await LoadXaml<StackPanel>($$"""
577+
<StackPanel>
578+
<TextBox Style="{StaticResource MaterialDesignFilledTextBox}"
579+
materialDesign:HintAssist.Hint="Hint text"
580+
VerticalContentAlignment="{{alignment}}"
581+
AcceptsReturn="True"
582+
Height="200" />
583+
</StackPanel>
584+
""");
585+
586+
IVisualElement<TextBox> textBox = await stackPanel.GetElement<TextBox>("/TextBox");
587+
IVisualElement<Grid> hintClippingGrid = await textBox.GetElement<Grid>("HintClippingGrid");
588+
589+
Assert.Equal(expectedFloatingHintAlignment, await hintClippingGrid.GetVerticalAlignment());
590+
591+
recorder.Success();
592+
}
565593
}
566594

567595
public class NotEmptyValidationRule : ValidationRule

0 commit comments

Comments
 (0)