c# - data binding property of a other control to a style while animating it -


i'm trying implement tab style radio button. style contains textblock child of grid changes it's color when checked , grid child of border element.

i'm trying bind grid's background when in checked state button end's bieng transparent

                                </visualstate>                             </visualstategroup>                              <visualstategroup x:name="checkstates">                                 <visualstate x:name="checked">                                     <storyboard>                                         <doubleanimation duration="0" to="1" storyboard.targetproperty="(uielement.opacity)" storyboard.targetname="contentpresenter" d:isoptimized="true"/>                                         <objectanimationusingkeyframes storyboard.targetproperty="(panel.background)" storyboard.targetname="checkedvisual">                                             <discreteobjectkeyframe keytime="0">                                                 <discreteobjectkeyframe.value>                                                     <solidcolorbrush color="#ff9977"/>                                                 </discreteobjectkeyframe.value>                                             </discreteobjectkeyframe>                                         </objectanimationusingkeyframes>                                     </storyboard>                                 </visualstate>                                 <visualstate x:name="unchecked"/>                                 <visualstate x:name="indeterminate"/>                             </visualstategroup>                              <visualstategroup x:name="focusstates">                                 <visualstate x:name="focused"/>                                 <visualstate x:name="unfocused"/>                                 <visualstate x:name="pointerfocused"/>                             </visualstategroup>                          </visualstatemanager.visualstategroups>                          <grid x:name="checkedvisual" width="{templatebinding width}"                                    height="{templatebinding height}"                                     opacity="{templatebinding opacity}"                                    horizontalalignment="{templatebinding horizontalalignment}"                                    verticalalignment="{templatebinding verticalalignment}" background="transparent">                             <contentpresenter x:name="contentpresenter" automationproperties.accessibilityview="raw" contenttemplate="{templatebinding contenttemplate}" contenttransitions="{templatebinding contenttransitions}" content="{templatebinding content}" horizontalalignment="{templatebinding horizontalcontentalignment}" margin="{templatebinding padding}" verticalalignment="{templatebinding verticalcontentalignment}" d:layoutoverrides="topposition, bottomposition" opacity="0.6" rendertransformorigin="0.5,0.5">                                 <contentpresenter.rendertransform>                                     <compositetransform/>                                 </contentpresenter.rendertransform>                             </contentpresenter>                         </grid>                      </border>                 </controltemplate>             </setter.value>         </setter>     </style> 

i've tried binding grid x:name="checkedvisual" 's backgroundproperty {templatebinding background}

the problem in part of code

<visualstategroup x:name="checkstates">                                  <visualstate x:name="checked">                                     <storyboard>                                         <doubleanimation duration="0" to="1" storyboard.targetproperty="(uielement.opacity)" storyboard.targetname="contentpresenter" d:isoptimized="true"/>                                         <objectanimationusingkeyframes storyboard.targetproperty="(panel.background)" storyboard.targetname="checkedvisual">                                             <discreteobjectkeyframe keytime="0">                                                 <discreteobjectkeyframe.value>                                                     <solidcolorbrush color="{templatebinding background}"/>                                                 </discreteobjectkeyframe.value>                                             </discreteobjectkeyframe>                                         </objectanimationusingkeyframes>                                     </storyboard>                                 </visualstate>                                 <visualstate x:name="unchecked"/>                                 <visualstate x:name="indeterminate"/>                             </visualstategroup>                             <visualstategroup x:name="focusstates">                                 <visualstate x:name="focused"/>                                 <visualstate x:name="unfocused"/>                                 <visualstate x:name="pointerfocused"/>                             </visualstategroup> 

when radio button checked opacity going 1 expected colour isn't changing . i've tried {binding background} .. changing statoc color works eg: "#117755".

can please guide me.. end result i'm aiming @ changing backgrund of grid when checked stated .. , color should changed binded value of background.

you can't according docs: https://msdn.microsoft.com/en-us/library/ms742868.aspx?f=255&mspperror=-2147217396

"animate in controltemplate"

you can't use dynamic resource references or data binding expressions set storyboard or animation property values. that's because inside controltemplate must thread-safe, , timing system must freeze storyboard objects make them thread-safe. storyboard cannot frozen if or child timelines contain dynamic resource references or data binding expressions. more information freezing , other freezable features, see freezable objects overview.

what have separate rectangle/border/something behind elements background bound wanted color , animate it's opacity instead. it'll same, won't run issue.


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -