自动调整 TabItem/StackPanel 内 WPF 框架对象的大小
我希望框架控件自动调整大小以填充 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这有效,关键部分是不设置第二个 RowDefinition Height=“Auto”,但第一行需要设置它,否则框架仅填充屏幕的大约 1/2,请看图...
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...