0

This is code of watermarktextbox.

<xctk:WatermarkTextBox Watermark="Enter First Name" />

How would I measure the height of that object?

Draken
  • 3,134
  • 13
  • 34
  • 54
miten
  • 29
  • 1
  • 3

1 Answers1

0

It is simple as this :

Assign a name to your component and measure its height using Height property in code behind.

XAML :

<xctk:WatermarkTextBox x:Name="WatermarkTextBox1" Watermark="Enter First Name" />

Codebehind :

var height = WatermarkTextBox1.Height;

EDIT : Please use this to get font height. Source : https://stackoverflow.com/a/9251215/5621607

private int GetTextHeight(TextBox tBox) 
{
  return TextRenderer.MeasureText(tBox.Text, tBox.Font, tBox.ClientSize,
           TextFormatFlags.WordBreak | TextFormatFlags.TextBoxControl).Height;
}
Community
  • 1
  • 1
ViVi
  • 4,339
  • 8
  • 29
  • 52