xaml - Events of DataTemplate don't work when it is loaded from outside of the page -


if add datatemplate standardstyles.xaml button event doesn't work. here code:

standardstyles.xaml

<datatemplate x:name="testtemplate">     <button x:name="testbutton" width="32" height="32" click="testbutton_click"/> </datatemplate> 

mypage.xaml

<flipview x:name="flipview" itemtemplate="{staticresource testtemplate}"> </flipview> 

mypage.xaml.cs

private void testbutton_click(object sender, routedeventargs e) {     debug.writeline("event works!!"); }    

if click on button nothing happens. styles loading correctly qua layout. when add template inside mypage.xaml page resource or directly inside flipview control works fine. example, works:

<!-- mypage.xaml --> <flipview x:name="flipview" >   <flipview.itemtemplate>     <datatemplate x:name="testtemplate">       <button x:name="testbutton" width="32" height="32" click="testbutton_click"/>     </datatemplate>   </flipview.itemtemplate> </flipview> 

why event doesn't work when template loaded outside of page?


Comments