自动调整 TabItem/StackPanel 内 WPF 框架对象的大小

发布于 2024-09-14 05:31:09 字数 841 浏览 13 评论 0原文

我希望框架控件自动调整大小以填充 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>

I want the Frame Control to automatically resize to fill the screen inside my TabItem. Is the following code it renders a very small frame. I would rather not set static heigh and width. Here is the 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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

凝望流年 2024-09-21 05:31:09

这有效,关键部分是不设置第二个 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>

This worked, the key part being not setting the second RowDefinition Height="Auto" but the first row needs to have it set or the frame only fills about 1/2 of the screen, go figure...

            <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>
九局 2024-09-21 05:31:09
<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 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> 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文