c# - how can i use a control in template? -


<style x:key="abc" targettype="{x:type window}">     <setter property="template">         <setter.value>             <controltemplate targettype="{x:type window}">                 <button x:name="btn">my button!!</button>             </controltemplate>         </setter.value>     </setter> </style> ... <window ... style="{staticresource stylemainwindow}"> 

how can use button btn?

come expectations,

messagebox.show(this.btn1.name); 

was occured error @ compile time. , btn1 didn't show in intelisense.

try findname method on controltemplate class.

assuming this control's context:

var button = (button)this.template.findname("btn", this); 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -