gpt4 book ai didi

c# - WPF - 将窗口大小设置为子用户控件大小

转载 作者:行者123 更新时间:2023-12-02 04:34:32 27 4
gpt4 key购买 nike

我有一个选项卡控件,它动态填充包含各种大小的用户控件的选项卡。打开选项卡时,我希望窗口自动调整大小,以适应事件用户控件的需要。有没有一种干净的方法可以做到这一点?

我正在使用标准 mvvm 模式。

最佳答案

使用Window类的SizeToContent属性。

<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow"
SizeToContent='Width'>
<Grid>
<Button Width='200' Content='The Button' />
</Grid>
</Window>

关于c# - WPF - 将窗口大小设置为子用户控件大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21149391/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com