0

In a canvas, I layout my controls myself through code. I use SetValue(Canvas.TopProperty),SetValue(Canvas.LeftProperty), Width and Height properties. I give a default height as 24 and 2 textboxes that should be rendered on top of each other seems overlapping. When I set the height to 30, this doesn't happen and textboxes render on top of each other correctly. I was thinking that maybe UWP assumes textbox height to be some minimum value more than 24 and extends it anyway. Does UWP assume a minimum textbox height or what might be happening in my case?

neo
  • 1,952
  • 2
  • 19
  • 39

1 Answers1

0

Yes, the TextBox has a MinHeight of 32 as defined by the default style via the TextControlThemeMinHeight ThemeResource.

You can easily find that by inspecting the application at runtime with the Live Visual Tree and Live Property Explorer in Visual Studio

*when you set the Height to 30, you don't notice overlapping because of the padding (10,3,6,5) and border thickness (2).

AlexDrenea
  • 7,981
  • 1
  • 32
  • 49
  • I see. I have one more question. I have to calculate the size of string with a certain font size and family. I use TextBlock, and set all properties like font, etc. Then I call Measure method of the TextBlock and then read DesiredSize property to determine how much space I should allocate on the canvas for TextBlock with certain string. Desired size comes out wrong. – neo Aug 04 '16 at 14:55
  • That's a separate question. Seems like it's been answered already - http://stackoverflow.com/questions/35969056/how-can-i-measure-the-text-size-in-uwp-apps – AlexDrenea Aug 04 '16 at 14:56
  • That's exactly what I do, but that question's answer doesn't work for me. – neo Aug 04 '16 at 14:58