2010-08-12 41 views
1

我想讓框架控件自動調整大小以填充我的TabItem中的屏幕。它是下面的代碼它呈現一個非常小的框架。我寧願不設置靜態高度和寬度。這裏是XAML在TabItem/StackPanel中自動調整WPF框架對象的大小

<TabItem Header="Reports" Name="tReports" Height="50" BorderBrush="Transparent" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="100"> 
      <Grid> 
       <Grid.RowDefinitions> 
        <RowDefinition /> 
        <RowDefinition /> 
       </Grid.RowDefinitions> 
       <ComboBox Grid.Row="0" Name="cmbReport" Width="200" HorizontalAlignment="Left" /> 
       <Frame Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Source="http://online/home/" Margin="0,15,0,0" /> 
      </Grid> 
      </TabItem> 

回答

2

這個工作,關鍵部分是未設置第二RowDefinition高度=「自動」,但在第一行需要有它設置或框架僅填充的1/2左右屏幕,去圖...

  <TabItem Header="Reports" Name="tReports" Height="50" BorderBrush="Transparent" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="100"> 
       <Grid> 
        <Grid.RowDefinitions> 
         <RowDefinition Height="Auto" /> 
         <RowDefinition /> 
        </Grid.RowDefinitions> 
        <ComboBox Grid.Row="0" Name="cmbReport" Width="200" HorizontalAlignment="Left"> 
        </ComboBox> 
        <Frame Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Source="http://online/home/" Margin="0,15,0,0" /> 
       </Grid> 
      </TabItem> 
1
<TabItem Header="Reports" Name="tReports" Height="50" BorderBrush="Transparent" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="100"> 
     <Grid> 
       <Frame HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Source="http://google.com" /> 
     </Grid> 
</TabItem> 
+0

謝謝,這有幫助。我還需要提到我必須在TabItem控件中添加另一個控件。一旦我另一個控件框架沒有垂直填充。請參閱我的原始問題以獲取更新XAML。 – knockando 2010-08-12 15:23:21