保证金价值类型的资源

7 xaml styles staticresource

我想将保证金设置为所有页面的默认值.对于我使用的高度

    <System:Double x:Key="Height">20</System:Double>
Run Code Online (Sandbox Code Playgroud)

但保证金是'0,2,0,0'我必须使用的类型是什么?

我不想使用样式和设置器.

Chr*_* W. 19

因为Margin你想要Thickness属性来设置它,所以代替System:Double try;

<Thickness x:Key="Height" Left="0" Top="2" Right="0" Bottom="0" />

<Button Margin="{StaticResource Height}" Content="Hey I have a Margin now"/>
Run Code Online (Sandbox Code Playgroud)

希望这可以帮助.

  • 我在WinRT中使用它并得到一个错误:`WMC0100:XAML厚度类型无法构造.解决了`<厚度x:键="高度"> 0,2,0,0 </厚度>`.请参阅http://stackoverflow.com/questions/30238734/xaml-margin-in-resources (2认同)