我有一个 Grid 控件,我想在 XAML 中设置边距属性并将它们从SystemInformation.CaptionHeight
. 我已经想出了如何在 C# 中做到这一点,但我想在 XAML 中做到这一点。
我以前没有使用资源来设置这样的东西,但我尝试过类似的变体
<Grid>
<Grid.Margin>
<Thickness Top="{StaticResource {x:Static Forms:SystemInformation.CaptionHeight}}" Left="5" Right="5" Bottom="5" />
</Grid.Margin>
</Grid>
和
<Grid>
<Grid.Margin>
<Thickness Top="{x:Static Forms:SystemInformation.CaptionHeight}" Left="5" Right="5" Bottom="5" />
</Grid.Margin>
</Grid>
但无济于事。如何在运行时动态设置这样的属性?