silverlight - Textblock not retrieving new style on property changed -


i using silverlight 5 , trying style binding viewmodel. i'm running issue binding not setting new value when property changes. happens default style, if use key works correctly. here examples.

this works:

<style x:key="headertextstyle" targettype="textblock">     <setter property="foreground" value="{binding foregroundbrush, source={staticresource theme}}"/>     <setter property="fontsize" value="15"/>     <setter property="fontweight" value="bold"/>     <setter property="textwrapping" value="wrap"/>     <setter property="margin" value="0,15,0,4"/>     <setter property="horizontalalignment" value="left"/> </style> 

this doesn't work:

<style targettype="textblock">     <setter property="foreground" value="{binding foregroundbrush, source={staticresource theme}}"/>     <setter property="fontsize" value="15"/>     <setter property="fontweight" value="bold"/>     <setter property="textwrapping" value="wrap"/>     <setter property="margin" value="0,15,0,4"/>     <setter property="horizontalalignment" value="left"/> </style> 

in first example when propertychanged event called rebinds foreground color correct value. in second example doesn't rebind.

any ideas?

as can remember, style declared x:key property, , if want set style default targettype, use basedon property. like...

<style x:key="headertextstyle" targettype="textblock">     <setter property="foreground" value="{binding foregroundbrush, source={staticresource theme}}"/>     ... </style>  <style targettype="textblock" basedon="{staticresource headertextstyle}" /> 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -