Thursday 15 April 2010

xaml - Windows Phone - Disabled Button Background -



xaml - Windows Phone - Disabled Button Background -

here i'm 1 time more question windows phone.

i created custom buttons , utilize background on buttons. created grayed button show disabled button.

but if disable using button1.isenabled = false, background disappear

searching on net found way using style tag, never used before. tried but, it's aways returns me problem, can give me example? code:

class="lang-xaml prettyprint-override"><button x:name="btsalvar" content="salvar cor" margin="68,477,70,0" verticalalignment="top" borderbrush="{x:null}" borderthickness="0" height="100" click="btsalvar_click" clickmode="press" isenabled="true" foreground="white"> <button.style> <style.triggers> <trigger property="isenabled" value="false"> <setter property="background" value="/imagens/buttons/buttongray01.png"/> </trigger> </style.triggers> </button.style> </button>

is there way utilize style in windows phone 8.1 or way set custom background on button isdisabled = false?

far know style triggers wpf thing not wp8.1/win8.1

so have utilize visual state manager want do. go ui designer go document outline on left side of vs2013. find button, right click > edit template -> edit copy. create custom style specific button.

you want alter disable state of button alter to.....

class="lang-xaml prettyprint-override">... <visualstate x:name="disabled"> <storyboard> <objectanimationusingkeyframes storyboard.targetproperty="foreground" storyboard.targetname="contentpresenter"> <discreteobjectkeyframe keytime="0" value="{themeresource buttondisabledforegroundthemebrush}"/> </objectanimationusingkeyframes> <objectanimationusingkeyframes storyboard.targetproperty="borderbrush" storyboard.targetname="border"> <discreteobjectkeyframe keytime="0" value="{themeresource buttondisabledborderthemebrush}"/> </objectanimationusingkeyframes> <!-- here need alter --> <objectanimationusingkeyframes storyboard.targetproperty="(border.background).(imagebrush.imagesource)" storyboard.targetname="border"> <discreteobjectkeyframe keytime="0" value="assets/your_image.png"/> </objectanimationusingkeyframes> </storyboard> </visualstate> ....

now if set new style style of button, want.

xaml windows-phone-8.1 visualstatemanager

No comments:

Post a Comment