Auth Infant
Auth Infant

Reputation: 1975

Can you define a Thickness static resource in UWP XAML that references another static resource (double) for one of its values?

I would like to define a double that will always be the left margin value in two difference Thickness values, both of which will be used in multiple places. E.g.:

<x:Double x:Key="BreadcrumbElementLeftMargin">23</x:Double>

<Thickness x:Key="BreadcrumbTextElementMargin">(reference value 23 above),20,0,0</Thickness>
<Thickness x:Key="BreadcrumbImageElementMargin">(reference value 23 above),40,0,0</Thickness>

Is there a way to do that?

Upvotes: 2

Views: 439

Answers (1)

Emond
Emond

Reputation: 50672

No, this is not possible in UWP because in UWP Thickness has no default constructor so the Left, Top, Right and Bottom properties cannot be set individually.

Side note: In WPF this can be done like this:

<x:Double x:Key="BreadcrumbElementLeftMargin">23</x:Double>

<Thickness x:Key="BreadcrumbTextElementMargin"
           Bottom="0"
           Left="{StaticResource BreadcrumbElementLeftMargin}"
           Right="0"
           Top="20" />

<Thickness x:Key="BreadcrumbImageElementMargin"
           Bottom="0"
           Left="{StaticResource BreadcrumbElementLeftMargin}"
           Right="0"
           Top="40" />

Upvotes: 2

Related Questions