문제

I want to set margin as default for all page. For height i used

    <System:Double x:Key="Height">20</System:Double>

But margin is '0,2,0,0' what the type i have to use?

I don't want to use style and setter.

도움이 되었습니까?

해결책

For Margin you want the Thickness attributes to set it, so instead of a 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"/>

Hope this helps.

다른 팁

Try this simplified way of defining Margin as a resource.

    <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-->
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top