How to make a plain text-only Silverlight button? -
i want button no background or other plain text. have done following , button not show @ all:
<usercontrol.resources> <controltemplate x:key="linkbuttons" targettype="button"> <textblock foreground="white" fontsize="28" fontfamily="verdana" padding="10"></textblock> </controltemplate> </usercontrol.resources> <button template="{staticresource linkbuttons}" content="hello world!"/>
the problem button designed have content, not text - it's kind of contentcontrol. so, display content, template should have in it:
<contentpresenter x:name="contentpresenter" content="{templatebinding content}" contenttemplate="{templatebinding contenttemplate}" verticalalignment="{templatebinding verticalcontentalignment}" horizontalalignment="{templatebinding horizontalcontentalignment}" margin="{templatebinding padding}"/>
or, make custom control based on button, add text property it, use current textblock control in template (but text="{binding text}"
) , leave contentpresenter out of template. making custom control little trickier making template existing one, it's best way you're going for.
Comments
Post a Comment