Applying ControlTemplate to Textbox causes .Text to become blank (Silverlight) -


i have bunch of textboxes on xaml page wanted same size. created control template , put in grid.resources section of page

<grid.resources>     <controltemplate x:key="basictextbox" targettype="textbox" >         <textbox minwidth="200" />     </controltemplate> </grid.resources> 

and apply textbox following:

<textbox x:name="txtnewsec1" template="{staticresource basictextbox}"/> 

i have button user can press , in code behind take text user has entered , apply object. surprised everytime when text come blank when text in textbox. after removing template textbox , clicking button again, text magically available during button's click event handler. there have set in controltemplate allow textbox have text during code-behind events? or sort of bug in silverlight?

you shouldn't use control template achieve want do. need is... styling (tada)

<grid.resources>   <style x:key="basictextbox" targettype="textbox">     <setter property="minwidth" value="200"/>   </style> </grid.resources> 

and:

<textbox x:name="txtnewsec1" style="{staticresource basictextbox}"/> 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -