Change the Style/Templete in runtime


hi,

i want to change style/templete of button using code in runtime
 
any examples ?

prasad - www.beautifulmind.blog.co.in

  hi,

myself figured out here answer.

<window
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 x:class="untitledproject1.window7"
 x:name="window"
 title="window7"
 width="640" height="480">
 <window.resources>
  <style x:key="buttonstyledemo" targettype="{x:type button}">
   <setter property="foreground" value="#ff2f29fb"/>
  </style>  
 </window.resources>
 <grid x:name="layoutroot">
  <button horizontalalignment="left" margin="98,0,0,126" verticalalignment="bottom" width="146" height="59" content="button" x:name="button1" click="button1_click" />
 </grid>
</window>

in .cs file

private void button1_click(object sender, routedeventargs e)

{

button1.style = this.resources["buttonstyledemo"] as style;

}


prasad - www.beautifulmind.blog.co.in


Expression  >  Expression Blend + SketchFlow



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

How to Share webservice object to all user

How to fix error Msg 1801, Level 16, State 3, Line 1