wpf - XAML - Text is not showing in my textbox after I styled it -


so, styled textboxes in app i'm working on, , of sudden can't see text i've bound textboxes. feel i'm missing kind of contentpresenter. anyway, here styling.

<style targettype="{x:type textbox}">     <setter property="height" value="26"/>     <setter property="template">         <setter.value>             <controltemplate targettype="textbox">                 <border borderthickness="{templatebinding borderthickness}"                         borderbrush="{templatebinding borderbrush}"                         background="{templatebinding background}">                 </border>                 <controltemplate.triggers>                     <trigger property="isenabled" value="false">                         <setter value="#ff2f2f2f" property="background"/>                         <setter value="white" property="foreground"/>                     </trigger>                 </controltemplate.triggers>             </controltemplate>         </setter.value>     </setter> </style> 

and here how textboxes set up

<textbox grid.row="2" grid.column="5" borderthickness="1" text="{binding variablename}"> 

any thoughts?

your hunch right, need have template part name part_contenthost inside controltemplate:

<controltemplate targettype="textbox">     <border borderthickness="{templatebinding borderthickness}"                     borderbrush="{templatebinding borderbrush}"                     background="{templatebinding background}">         <scrollviewer margin="0"                     x:name="part_contenthost" />     <!-- ... --> 

this because controltemplate textbox requires part name part_contenthost. can view controltemplate examples built-in controls find out named template parts required , each part must able in order retain normal functionality.


Comments