tags:

views:

19

answers:

1

Hi,

I want to change the just the left margin of a WPF textbox via XAML:

This code obviously does not work :

<TextBox Margin.Left ="0"/>

What would be the correct code, does anyone here know ?

Regards, MadSeb

+1  A: 

I can't see your code - but it would normally go like this:

<TextBox Margin="5 0 0 0"/>

First number is left, then top, then right and finally bottom margin.

Hope this helps!

Goblin
thanks for the reply...what I want to do is to change the left to 5 but without setting the top,right,bottom to 0 !
MadSeb
i would use commas: Margin="0,0,0,0" it makes it easier to read
Muad'Dib
@MadSeb: The value is of type Thickness - which means it is a all-or-nothing setter. You can do it in code-behind tho.
Goblin
. @MuadDib: All a matter of taste - I find commas irritating :-)
Goblin
You can place the TextBlock inside a Canvas and set Canvas.Left attached property in the TextBlock. Like <canvas><TextBlock Canvas.Left="5" /> </Canvas>
Avatar
@Avatar: Great idea! Should probably use a DockPanel instead, though to get the TextBox to fill - and set the Padding="5 0 0 0" on the DockPanel.
Goblin
Yeah that as well
Avatar