wpf - Template.FindName returns null while accessing control inside data template -


i trying access checkbox in datagrid's column header in code behind template.findname returns null. can tell me doing wrong here ?

here code behind:

   private void mycheckbox_checked(object sender, routedeventargs e)     {         var template = mygrid.template;         var mycheckbox = (checkbox)template.findname("mychkbxall", this.mygrid);     } 

xaml:

<grid>     <datagrid name="mygrid" margin="0,10,0,0" headersvisibility="column" verticalalignment="top" fontsize="14" width="280" height="220" maxwidth="700" minwidth="200" background="#fff3f3f3" rowbackground="#ff37aec9" alternatingrowbackground="lightblue" horizontalalignment="center" canuseraddrows="false"  keyboardnavigation.tabnavigation="none" autogeneratecolumns="true" gridlinesvisibility="none" isreadonly="true" virtualizingstackpanel.virtualizationmode="standard" columnwidth="*" horizontalscrollbarvisibility="auto" selectionchanged="installablegrid_selectionchanged">         <datagrid.columns>             <datagridcheckboxcolumn header="select" elementstyle="{staticresource  checkboxstyleinverted}" width="auto" >                 <datagridcheckboxcolumn.headertemplate >                     <datatemplate x:name="mychkbx">                         <checkbox x:name="mychkbxall" style="{staticresource  checkboxstyleinverted}" margin="-3.2,0,0,0" horizontalalignment="left" checked="mycheckbox_checked" width="50" height="30"/>                     </datatemplate>                 </datagridcheckboxcolumn.headertemplate>             </datagridcheckboxcolumn>         </datagrid.columns>     </datagrid> </grid> 


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -