2013-08-07 114 views
0

我什麼時候Border容器的大小足夠寬:WPF。的TextBlock和TextBox對齊正確

Name Value NameLonger Value

那麼Border尺寸變得更小,我有這樣的事情:

名稱值NameLonger V

我使用WrapPanel,並取得如下效果:

Name Value 
NameLonger Value 

它是更好,但我想實現這樣的事情:

Name  Value 
NameLonger Value 

是否有可能實現這樣的事情?

回答

1

不知道我是否完全理解你解釋的內容,但根據我認爲你所描述的內容,這是你要找的嗎?

<Border> 
<Grid> 
     <Grid.ColumnDefinitions> 
      <ColumnDefinition Width="Auto"></ColumnDefinition> 
      <ColumnDefinition Width="Auto"></ColumnDefinition> 
     </Grid.ColumnDefinitions> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="Auto"></RowDefinition> 
      <RowDefinition Height="Auto"></RowDefinition> 
     </Grid.RowDefinitions> 
<!--Put your textblocks in here--> 
</Grid> 
</Border> 
+0

這種解決方案並不能使我的改變位置時,夫妻的邊界改變其寬度...... –

+0

我想我不明白你試圖完成什麼依然。 – bflosabre91

0

使用網格作爲容器面板。將第一列寬設置爲使用其所需的寬度("auto"),第二列使用其餘列("*")。 將第一列中的textblock和第二列中的textbox

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


<textblock .../> 
<textbox grid.column="1".../> 
    </Grid> 
+0

當邊框寬度變化時,此解決方案不會讓我的夫婦更改位置... –