2017-06-29 173 views
0

這是我的代碼;我想添加引用renderere屬性

<StackLayout> 
    <StackLayout.BackgroundColor> 
     <OnPlatform x:TypeArguments="Color" Android="#ff1500" iOS="Transparent"></OnPlatform> 
    </StackLayout.BackgroundColor> 
</StackLayout> 

我想補充參考屬性renderere像這樣:

<StackLayout> 
    <StackLayout.BackgroundColor> 
     <OnPlatform x:TypeArguments="Color" Android="{controls:GradientColors StartColor="#373737" EndColor="#191919"}" iOS="Transparent"></OnPlatform> 
    </StackLayout.BackgroundColor> 
</StackLayout> 

我怎麼辦呢?

+0

你需要創建BindibleProperty –

+0

你能舉個例子嗎?感謝 –

+0

其中之一:https://xamarinhelp.com/bindable-properties-xamarin-forms/如果您需要使用屬性更改顏色,然後綁定道具會做,但如果您還需要使用自定義細節(如漸變等) )然後@JordyDieltjens是對的,你還需要自定義渲染器 –

回答

0

你可以做的是爲Stacklayout製作一個渲染器,讓我們說CustomStackLayout。

而不是在每個平臺上更改backgroundcolor。