简体   繁体   中英

textbox in c# (wp7) in 1 line

I have problem with 2 Textblocks in my WP7 project (in expression blend).

I put them [text block][text block] in a grid, and the problem is that text of 1st text block is random, once got 5 char, once 10 char, and first text block is on second text block.

example:

[First Text][Second Text]
[First Text Dadada] Text]

I would like to make them:

[First Text][Second Text]
[First Text Dadadda][Second Text]

将每个文本框放在其自己的网格列中( Grid.Column="..."属性指定) 将它们包装到指定Orientation=HorizontalStackPanel

Your grid should be automatically resizable and both textBlocks should be assigned their respective columns.

Example, consider the following grid layout for your problem:

<Grid>
   <Grid.ColumnDefinitions>
      <ColumnDefinition Width="Auto"/>
      <ColumnDefinition Width="Auto"/>
   </Grid.ColumnDefinitions>
</Grid>

Now, assign columns to your textBlocks (declared inside the grid), eg:

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="Auto"/>
    </Grid.ColumnDefinitions>
    <TextBlock Grid.Column="0"/>
    <TextBlock Grid.Column="1"/>
</Grid>

That should do it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM