【问题标题】:Automatically Size WPF Frame Object inside TabItem/StackPanel在 TabItem/StackPanel 中自动调整 WPF 框架对象的大小
【发布时间】:2011-03-28 22:58:10
【问题描述】:

我希望框架控件自动调整大小以填充我的 TabItem 内的屏幕。以下代码是否呈现一个非常小的框架。我宁愿不设置静态高度和宽度。这是 XAML

<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>

【问题讨论】:

    标签: wpf frame autosize


    【解决方案1】:

    这行得通,关键部分是没有设置第二个 RowDefinition Height="Auto" 但第一行需要设置它或者框架只填充大约 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>
    

    【讨论】:

      【解决方案2】:
      <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> 
      

      【讨论】:

      • 谢谢,这有帮助。我还需要提到我必须在 TabItem 控件中添加另一个控件。一旦我另一个控制框架不会垂直填充。有关更新 XAML,请参阅我的原始问题。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多