2016-12-05 55 views
0

我想並排放置stackPanels。然後在每個堆棧面板中,有不同的控件。現在第一個堆棧面板正在工作。它有文本塊和文本框。現在我想在第二個堆棧面板上添加一個按鈕等等。問題是第二個面板不顯示按鈕的內容。不知道爲什麼?Stackpanels並排

<StackPanel Orientation="Vertical"> 
    <StackPanel Orientation="Horizontal" Width="300" HorizontalAlignment="Left" Margin="10"> 
     <Grid> 
      <Grid.ColumnDefinitions> 
       <ColumnDefinition></ColumnDefinition> 
       <ColumnDefinition></ColumnDefinition> 
       <ColumnDefinition></ColumnDefinition> 
      </Grid.ColumnDefinitions> 
      <Grid.RowDefinitions> 
       <RowDefinition></RowDefinition> 
       <RowDefinition></RowDefinition> 
      </Grid.RowDefinitions> 
      <StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Left"> 
       <Grid> 
        <Grid.ColumnDefinitions> 
         <ColumnDefinition Width="100"></ColumnDefinition> 
         <ColumnDefinition Width="100"></ColumnDefinition> 
         <ColumnDefinition Width="100"></ColumnDefinition> 
        </Grid.ColumnDefinitions> 
        <Grid.RowDefinitions> 
         <RowDefinition Height="25"></RowDefinition> 
         <RowDefinition Height="25"></RowDefinition> 
        </Grid.RowDefinitions> 
        <TextBlock Grid.Column="0" Grid.Row="0" Text="Year" TextAlignment="Center"></TextBlock> 
        <TextBlock Grid.Column="1" Grid.Row="0" Text="Week" TextAlignment="Center"></TextBlock> 
        <TextBlock Grid.Column="2" Grid.Row="0" Text="File Location" TextAlignment="Center"></TextBlock> 
       </Grid> 
      </StackPanel> 
      <StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="0" Margin="10"> 
       <Grid> 
        <Grid.ColumnDefinitions> 
         <ColumnDefinition></ColumnDefinition> 
         <ColumnDefinition Width="100"></ColumnDefinition> 
         <ColumnDefinition Width="100"></ColumnDefinition> 
        </Grid.ColumnDefinitions> 
        <Grid.RowDefinitions> 
         <RowDefinition Height="Auto"></RowDefinition> 
        </Grid.RowDefinitions> 
        <Button Grid.Column="0" Grid.Row="0"> 
         <TextBlock Text="Get Informations" TextWrapping="Wrap" TextAlignment="Center"></TextBlock> 
        </Button> 
       </Grid> 
      </StackPanel> 
      <StackPanel Orientation="Horizontal" Grid.Column="2" Grid.Row="0"></StackPanel> 
      <StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="1"></StackPanel> 
      <StackPanel Orientation="Horizontal" Grid.Column="2" Grid.Row="1"></StackPanel> 
     </Grid> 

    </StackPanel> 
</StackPanel> 

回答

1

如果您需要解決方案,您將Stackpanel的寬度設置爲300。要麼刪除stackpnael(寬度爲300的那個)或者將該堆疊面板內的Grid固定爲300

+0

這是正確的 - 兩個內部平行堆棧面板中的第二個被裁剪掉。 –