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
Post a Comment