Wednesday, 15 May 2013

windows phone 8.1 - Change in TextBox VisualState when it disable -



windows phone 8.1 - Change in TextBox VisualState when it disable -

how can stop textbox visualstate alter when alter isenabled property of textbox?

in other word, how can create textbox visually looks same when set disable , set enable?

most of things aren't in property page of command visually done through <style>, edit <style> of command navigate document outline (it's on left of visual studio)

document outline > find textbox > right click > edit template > edit copy

at point create default template particular textbox, have comment out storyboard elements of <visualstate x:name="disabled"> so:

class="lang-xaml prettyprint-override"><style x:key="textboxstyle1" targettype="textbox"> <setter property="minwidth" value="{themeresource textcontrolthememinwidth}"/> <setter property="minheight" value="{themeresource textcontrolthememinheight}"/> <setter property="foreground" value="{themeresource textboxforegroundthemebrush}"/> <setter property="selectionhighlightcolor" value="{themeresource textselectionhighlightcolorthemebrush}"/> <setter property="background" value="{themeresource textboxbackgroundthemebrush}"/> <setter property="borderbrush" value="{themeresource textboxborderthemebrush}"/> <setter property="borderthickness" value="{themeresource textcontrolborderthemethickness}"/> <setter property="fontfamily" value="{themeresource phonefontfamilynormal}"/> <setter property="fontsize" value="{themeresource contentcontrolfontsize}"/> <setter property="textwrapping" value="nowrap"/> <setter property="scrollviewer.horizontalscrollmode" value="auto"/> <setter property="scrollviewer.verticalscrollmode" value="auto"/> <setter property="scrollviewer.horizontalscrollbarvisibility" value="hidden"/> <setter property="scrollviewer.verticalscrollbarvisibility" value="hidden"/> <setter property="scrollviewer.isdeferredscrollingenabled" value="false"/> <setter property="padding" value="{themeresource textcontrolthemepadding}"/> <setter property="margin" value="{themeresource textcontrolmarginthemethickness}"/> <setter property="verticalalignment" value="top"/> <setter property="template"> <setter.value> <controltemplate targettype="textbox"> <grid> <grid.rowdefinitions> <rowdefinition height="auto"/> <rowdefinition height="*"/> </grid.rowdefinitions> <visualstatemanager.visualstategroups> <visualstategroup x:name="commonstates"> <visualstate x:name="disabled"> <!-- <storyboard> <objectanimationusingkeyframes storyboard.targetproperty="background" storyboard.targetname="backgroundelement"> <discreteobjectkeyframe keytime="0" value="{themeresource textboxdisabledbackgroundthemebrush}"/> </objectanimationusingkeyframes> <objectanimationusingkeyframes storyboard.targetproperty="borderbrush" storyboard.targetname="borderelement"> <discreteobjectkeyframe keytime="0" value="{themeresource textboxdisabledborderthemebrush}"/> </objectanimationusingkeyframes> <objectanimationusingkeyframes storyboard.targetproperty="foreground" storyboard.targetname="contentelement"> <discreteobjectkeyframe keytime="0" value="{themeresource textboxdisabledforegroundthemebrush}"/> </objectanimationusingkeyframes> <objectanimationusingkeyframes storyboard.targetproperty="foreground" storyboard.targetname="placeholdertextcontentpresenter"> <discreteobjectkeyframe keytime="0" value="{themeresource textboxdisabledforegroundthemebrush}"/> </objectanimationusingkeyframes> </storyboard> --> </visualstate> <visualstate x:name="normal"> <storyboard> <doubleanimation duration="0" to="{themeresource textcontrolbackgroundthemeopacity}" storyboard.targetproperty="opacity" storyboard.targetname="backgroundelement"/> <doubleanimation duration="0" to="{themeresource textcontrolborderthemeopacity}" storyboard.targetproperty="opacity" storyboard.targetname="borderelement"/> </storyboard> </visualstate> <visualstate x:name="focused"> <storyboard> <objectanimationusingkeyframes storyboard.targetproperty="borderbrush" storyboard.targetname="borderelement"> <discreteobjectkeyframe keytime="0" value="{themeresource textselectionhighlightcolorthemebrush}"/> </objectanimationusingkeyframes> <doubleanimation duration="0" to="0" storyboard.targetproperty="opacity" storyboard.targetname="placeholdertextcontentpresenter"/> <objectanimationusingkeyframes storyboard.targetproperty="background" storyboard.targetname="backgroundelement"> <discreteobjectkeyframe keytime="0" value="{themeresource textboxfocusedbackgroundthemebrush}"/> </objectanimationusingkeyframes> </storyboard> </visualstate> </visualstategroup> </visualstatemanager.visualstategroups> <border x:name="backgroundelement" background="{templatebinding background}" margin="{templatebinding borderthickness}" grid.row="1"/> <border x:name="borderelement" borderbrush="{templatebinding borderbrush}" borderthickness="{templatebinding borderthickness}" grid.row="1"/> <contentpresenter x:name="headercontentpresenter" contenttemplate="{templatebinding headertemplate}" content="{templatebinding header}" margin="{themeresource textcontrolheadermarginthemethickness}" grid.row="0" style="{staticresource headercontentpresenterstyle}"/> <scrollviewer x:name="contentelement" automationproperties.accessibilityview="raw" horizontalscrollmode="{templatebinding scrollviewer.horizontalscrollmode}" horizontalscrollbarvisibility="{templatebinding scrollviewer.horizontalscrollbarvisibility}" istabstop="false" ishorizontalrailenabled="{templatebinding scrollviewer.ishorizontalrailenabled}" isverticalrailenabled="{templatebinding scrollviewer.isverticalrailenabled}" isdeferredscrollingenabled="{templatebinding scrollviewer.isdeferredscrollingenabled}" margin="{templatebinding borderthickness}" minheight="{themeresource textcontrolthememinheight}" padding="{templatebinding padding}" grid.row="1" verticalscrollbarvisibility="{templatebinding scrollviewer.verticalscrollbarvisibility}" verticalscrollmode="{templatebinding scrollviewer.verticalscrollmode}" zoommode="disabled"/> <contentcontrol x:name="placeholdertextcontentpresenter" content="{templatebinding placeholdertext}" foreground="{themeresource textboxplaceholdertextthemebrush}" fontsize="{themeresource contentcontrolfontsize}" istabstop="false" margin="{templatebinding borderthickness}" padding="{templatebinding padding}" grid.row="1"/> </grid> </controltemplate> </setter.value> </setter> </style>

then

set textbox utilize style so:

class="lang-xaml prettyprint-override"><textbox isenabled="false" text="i have no thought when it's disabled now, since doesn't different" style="{staticresource textboxstyle1}"></textbox>

windows-phone-8.1

No comments:

Post a Comment