How to adjust registration on xaml shortcut

How can I make the top and bottom padding smaller on the next label? As I can see, the bounding box is much larger than it should be, but the padding is set to 0, so it cannot be smaller.

<Label Background="AliceBlue" Content="1800" FontSize="170" FontWeight="Bold" Foreground="Gray" Padding="0" /> 
+4
source share
6 answers

You can use Margin.

With a mark, you can set the amount that you want to leave left, right, top, bottom

by that I mean Margin="0,0,0,0" , which means. you don’t have anyone that would be so.

it takes the following: Margin ="left, top, right, bottom

so if i have margin ="2,5,3,5"

this means that I have a margin of 2 pixels on the left, 5 pixels on the top, 3 pixels on the right and 5 pixels up.

+3
source

Padding does not exist in XAML on FrameworkElement . Use margin.

Filling can be applied to three elements: Block , Border and Control , since these elements have an outer edge.

+2
source

Just by clicking on this where the border was around the label, I set a negative margin.

 <Border BorderBrush="Black" BorderThickness="1"> <Label Margin="-5" Content="Unable to report/> </Border> 
+2
source

If you can switch to using TextBlock, you can better manage the add-on. The purpose of the labels, apparently, is that the filling is fixed by its internal style. See " How to remove margins around text on a WPF shortcut? ".

0
source

Try to wrap the label in the layout, for example, StackLayout, and give an addition to this layout, then the label will align accordingly. This code can help you.

 <StackLayout Padding="10"> <Label x:Name="TitleLbl"></Label> </StackLayout> 
0
source

make your own PCL rendering :

  public class SALabel : Label { public static readonly BindableProperty PaddingProperty = BindableProperty.Create("Padding", typeof(Thickness), typeof(SALabel),default(Thickness)); public Thickness Padding { get { return (Thickness)GetValue(PaddingProperty); } set { SetValue(PaddingProperty, value); } } } 

in android

 Control.SetPadding((int)saElement.Padding.Left, (int)saElement.Padding.Top, (int)saElement.Padding.Right, (int)saElement.Padding.Bottom); 
0
source

All Articles