Thomasian
asked on
Remove WPF TextBox Additional Padding
How can I remove all padding/margin for a textbox control? I have already set margin and padding to zero but there's still space between controls.
XAML Code for the test app. I have included labels and textblocks controls in the test app to show what I mean.
XAML Code for the test app. I have included labels and textblocks controls in the test app to show what I mean.
<Window x:Class="Test"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Test" SizeToContent="WidthAndHeight">
<StackPanel>
<StackPanel Orientation="Horizontal">
<TextBox Text="ABCD" Padding="0" Margin="0" BorderThickness="0" FontFamily="Arial" FontSize="20" />
<TextBox Text="ABCD" Padding="0" Margin="0" BorderThickness="0" FontFamily="Arial" FontSize="20" />
<TextBox Text="ABCD" Padding="0" Margin="0" BorderThickness="0" FontFamily="Arial" FontSize="20" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="ABCD" Padding="0" Margin="0" BorderThickness="0" FontFamily="Arial" FontSize="20" />
<Label Content="ABCD" Padding="0" Margin="0" BorderThickness="0" FontFamily="Arial" FontSize="20" />
<Label Content="ABCD" Padding="0" Margin="0" BorderThickness="0" FontFamily="Arial" FontSize="20" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="ABCD" Padding="0" Margin="0" FontFamily="Arial" FontSize="20" />
<TextBlock Text="ABCD" Padding="0" Margin="0" FontFamily="Arial" FontSize="20" />
<TextBlock Text="ABCD" Padding="0" Margin="0" FontFamily="Arial" FontSize="20" />
</StackPanel>
</StackPanel>
</Window>
ResultASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What about the padding of the stackpanel in which the controls are put?
ASKER
StackPanel doesn't have a Padding property.
The -2 should only be needed for TextBox elements. The TextBox has an implied internal pad to set it apart from label, etc. So you need to forcibly remove it with the negative padding.
ASKER