user3548681
user3548681

Reputation:

wpf align 2 controls

i would like to have a textblock and texbox content one beside one.

                    <TextBlock  >ID: 
    <TextBox IsReadOnly="True" FontSize="25" Name="Pass"
     BorderThickness="0" Foreground="Orange"  
     Background="Transparent" 
    />
                    </TextBlock>

it actually works but they dont really in the same line. the texblock text(in this case ID is a little down and not actually in the same line. Thanks for any help.

Upvotes: 0

Views: 47

Answers (3)

Abin
Abin

Reputation: 2956

Try Like below,

<StackPanel Margin="5" Orientation="Horizontal">
    <TextBlock  Text="ID: "/>    
    <TextBox IsReadOnly="True" FontSize="25" Name="Pass"     BorderThickness="0" Foreground="Orange" Background="Transparent"     />
</StackPanel>

Upvotes: 1

electricalbah
electricalbah

Reputation: 2297

This is what you are looking for

 <TextBlock  Text="ID: "></TextBlock>
<TextBox IsReadOnly="True" FontSize="25" Name="Pass"     BorderThickness="0" Foreground="Orange" Background="Transparent"     />

Upvotes: 0

JustMeToo
JustMeToo

Reputation: 425

Why are you putting the textbox in the textblock? If you make them separate items, you can then place them however you want. But if you really want to do it in the textblock, I believe you can create a template and use that to align the controls.

Upvotes: 0

Related Questions