2012-02-25 21 views
0

我在ToolBarTray中有兩個ToolBars。儘管它們可以放在一行中,但我希望將每個ToolBar放在新行中。 我該怎麼做?ToolBarTray中新行的工具欄

<ToolBarTray VerticalAlignment="Top" Margin="0,20,70,0" Height="65"> 
    <ToolBar Height="30" VerticalAlignment="Top" Background="LightGray" > 
     <Label>Name :</Label> 
     <TextBox Width="120"></TextBox> 
     <ComboBox Width="120" Margin="5,0,0,0"> 
      <ComboBoxItem>Item 1</ComboBoxItem> 
      <ComboBoxItem>Item 2</ComboBoxItem> 
      <ComboBoxItem>Item 3</ComboBoxItem> 
     </ComboBox> 
     <Button Height="25" Width="80" Background="White" Margin="5,0,0,0">Search</Button> 
     <Label>This is a first ToolBar</Label> 
     <Button Height="25" Width="80" Background="White" Margin="5,0,0,0" ToolBar.OverflowMode="Always">Look for ..</Button> 
    </ToolBar> 

     <ToolBar Height="30" VerticalAlignment="Top" Background="LightGray"> 
      <Label>Name :</Label> 
      <TextBox Width="120"></TextBox> 
      <ComboBox Width="120" Margin="5,0,0,0"> 
       <ComboBoxItem>Item 1</ComboBoxItem> 
       <ComboBoxItem>Item 2</ComboBoxItem> 
       <ComboBoxItem>Item 3</ComboBoxItem> 
      </ComboBox> 
     </ToolBar> 
    </ToolBarTray> 

回答

2

MSDN: ToolBar.BandIndex Property

在ToolBarTray工具欄的位置取決於 的ToolBarTray.Orientation,樂隊,和BandIndex屬性的值。當 方向設置爲水平時,樂隊表示 ToolBarTray中的一行。當方向爲垂直時,帶表示ToolBarTray的列 。

在這種情況下,你需要的ToolBarTray.Orientation屬性設置爲Vertical

<ToolBarTray Orientation="Vertical" 
      VerticalAlignment="Top" Margin="0,20,70,0" Height="65"> 
    <etc /> 
</ToolBarTray> 

而且,不要忘了ToolBar.BandToolBar.BandIndex屬性:

如果你這樣做未明確設置此屬性,其值由 決定ToolBar在ToolBarTray中的設置順序。例如,如果將兩個工具欄放在ToolBarTray中,但沒有設置Band和 BandIndex屬性,則對於這兩個工具欄,Band的值將爲0,例如 。 對於第一個工具欄,BandIndex的值將爲0,對於 第二個工具欄,值將爲1。