LofiMAM
LofiMAM

Reputation: 127

Make some OnIdiom and OnPlatform StaticResource

I want to use StaticResource and benefits from auto complete of VS 2017 by using some syntax like this if it is exist:

<x:Double x:Key="NormalSpacing">
    <OnIdiom x:TypeArguments="x:Double">
        <OnIdiom.Phone>
            <OnPlatform x:TypeArguments="x:Double" iOS="7" Android="3" />
        </OnIdiom.Phone>
        <OnIdiom.Tablet>
            <OnPlatform x:TypeArguments="x:Double" iOS="15" Android="10" />
        </OnIdiom.Tablet>
    </OnIdiom>
</x:Double>

shortly I want to give the key to the main tag which contain OnIdiom and OnPlatform tags.

Upvotes: 2

Views: 659

Answers (1)

Ben
Ben

Reputation: 2995

Use a style for auto complete with the compact OnIdiom and OnPlatformsyntax:

<Style x:Key="stackLayoutStyle" TargetType="StackLayout">
    <Setter Property="Spacing" 
            Value="{OnIdiom 
        Phone  = {OnPlatform iOS=7,  Android=3   },
        Tablet = {OnPlatform iOS=15, Android=10 }}" >
    </Setter>
</Style>
...
<StackLayout Style="{StaticResource stackLayoutStyle}">
...
</StackLayout>

Upvotes: 2

Related Questions