This is code of watermarktextbox
.
<xctk:WatermarkTextBox Watermark="Enter First Name" />
How would I measure the height of that object?
This is code of watermarktextbox
.
<xctk:WatermarkTextBox Watermark="Enter First Name" />
How would I measure the height of that object?
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;
}