Xaml 资源中的边际价值类型

Xaml 资源中的边际价值类型,xaml,styles,staticresource,Xaml,Styles,Staticresource,我想为所有页面设置默认页边距。就我以前的身高而言 <System:Double x:Key="Height">20</System:Double> 20 但是边距是'0,2,0,0',我必须使用什么类型 我不想使用style和setter。对于Margin您希望使用Thickness属性来设置它,所以不要使用系统:双击 <Thickness x:Key="Height" Left="0" Top="2" Right="0" Bottom="0" />

我想为所有页面设置默认页边距。就我以前的身高而言

    <System:Double x:Key="Height">20</System:Double>
20
但是边距是'0,2,0,0',我必须使用什么类型


我不想使用style和setter。

对于
Margin
您希望使用
Thickness
属性来设置它,所以不要使用系统:双击

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

<Button Margin="{StaticResource Height}" Content="Hey I have a Margin now"/>


希望这能有所帮助。

试试这种将边距定义为资源的简化方法

    <Thickness x:Key="MarginCustom1">100</Thickness> <!--Sets L/T/R/B to 100-->
    <Thickness x:Key="MarginCustom2">10,20</Thickness> <!--Sets L/R to 10 and T/B to 20 -->
    <Thickness x:Key="MarginCustom3">10,10,10,10</Thickness> <!--Sets L/T/R/B respectively-->
100
10,20 
10,10,10,10 

我在WinRT中使用了它,得到了一个错误:
WMC0100:XAML厚度类型无法构造。
。用
0,2,0,0
求解。请参阅@stephenhosking,使用定义的Left=、Right=、等将其设置为我的示例中所示的值,而不是像您所示的字符串。