【发布时间】:2020-10-19 08:52:48
【问题描述】:
我正在尝试在 UWP 应用程序中构建用户控件,但我无法在 XAML 设计器中看到其“自动”大小(基于其内容)。
我知道我可以将 d:DesignHeight 和 d:DesignWidth 硬编码为绝对值,但由于大小应基于其内容,我不想硬编码这些值。
有没有类似 d:DesignHeight="Auto" / d:DesignWidth="Auto" 的东西?
例如- 对于下面的示例用户控件
<UserControl
x:Class="MyCompany.UserControls.MyUserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:MyCompany.UserControls.UserControls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<StackPanel>
<Button Content="First" />
<Button Content="Second" />
</StackPanel>
</UserControl>
我看到了
但是我想根据内容查看控件的大小。
【问题讨论】:
标签: visual-studio xaml uwp