2010-06-29 90 views
1

我試圖讓2個按鈕在旁邊,並均勻佔據「主區域」下的整行。WPF有控件填充整行

我似乎缺少一些東西

謝謝!

<Grid Background="Transparent" Margin="0" Opacity=".8"> 

    <Border Name="MaskBorder" Grid.RowSpan="3"> 
     <Border Name="MainBorder" Background="Aqua"> 
      <Grid> 

       <Grid.ColumnDefinitions> 
        <ColumnDefinition Width="30"/> 
        <ColumnDefinition Width="811*"/> 
        <ColumnDefinition Width="30"/> 
       </Grid.ColumnDefinitions> 

       <!--Body--> 
       <Grid Grid.ColumnSpan="4"> 
        <Border Name="BodyBackground" Background="White" /> 
       </Grid> 

       <!-- Main Area for Content --> 
       <Grid Name="ContentGrid" Grid.Column="1"> 
        <Grid.RowDefinitions> 
         <RowDefinition Height="55" /> 
         <RowDefinition Height="811*" /> 
         <RowDefinition Height="30" /> 
        </Grid.RowDefinitions> 

        <DockPanel LastChildFill="True" Grid.Row="1"> 

         <Grid DockPanel.Dock="Bottom"> 
          <Button Height="55"></Button> 
          <Button Height="55"></Button> 
         </Grid> 

         <Border Background="Black" /> 

        </DockPanel> 

       </Grid> 

      </Grid> 
     </Border> 
    </Border> 
</Grid> 

回答

1

您在同一個網格單元上有按鈕。嘗試:

<Grid DockPanel.Dock="Bottom"> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition/> 
     <ColumnDefinition/> 
    </Grid.ColumnDefinitions> 
    <Button Grid.Column="0" Height="55"></Button> 
    <Button Grid.Column="1" Height="55"></Button> 
</Grid> 
0

,你可以這樣使用替代DockPanle的StackPanel中:

<StackPanel Orientation="Vertical"> 
     <Button Height="55"/> 
     <Button Height="55"/> 
</StackPanel>