If you add the attribute
Padding="0, 0, 0, 0"
to most WPF elements e.g. <Label></Label>, the text is placed in the top left hand corner with no space between the left and top sides. However if you try it with a TextBox element it appears to have no effect.
Fortunately as a workaround you can set the padding to have negative values. So e.g. if I want a standard TextBox element, with standard fontsize, with no space above the text, doing something like:
Padding="0, -2, 0, 0"
Will have the desired effect.
Subscribe to:
Post Comments (Atom)
Hello, and thanks for posting on this subject. This does not appear to work for wpf textboxes in .net 4.0.
ReplyDeleteI am trying to do this and the designer tells me:
'0,-2,0,0' is not a valid value for property 'Padding'
Any other ideas?
It works for me. I did get that message when I was using a textblock, but it works with textboxes.
ReplyDelete'0,-2,0,0' is not a valid value for property 'Padding'
ReplyDeleteIgnore Anonymous above who says it worked.