Answered by:
Windows 8.1 DataTemplate in xaml resource file, Button click event is not called.

Question
-
Hi,
In my app for Windows 8.1 I declared a data template inside a Resource file for a ListView in order
to use it in more than one xaml pages. In the Data Template I have a button with che ClickEvent but this is not called
in the code behind of the page.
But If I declare the DataTemplate directly in the xaml page the click event is fired.
How I can get the click event of the button keeping the datatemplate in the resource page?
Thanks
Daniele.
Monday, August 5, 2013 7:17 AM
Answers
-
see this one: http://www.codeproject.com/Articles/274982/Commands-in-MVVM
Microsoft Certified Solutions Developer - Windows Store Apps Using C#
- Marked as answer by DanieleRM78 Monday, August 5, 2013 12:23 PM
Monday, August 5, 2013 9:34 AM
All replies
-
datatemplates in resource files cant have event handlers, to be true its quiet funny its running normal, can't you work with commands ?
Microsoft Certified Solutions Developer - Windows Store Apps Using C#
- Edited by Dave SmitsMVP Monday, August 5, 2013 8:25 AM
Monday, August 5, 2013 8:25 AM -
Hi,
thanks for the answer.
I have my dataTamplate declared in the app.xaml file.
So If I have understood well I have to use the commands in order to have the click event in the code behind of the my page?
Is there something example code which shows how the commands works?
Thanks
Daniele
Monday, August 5, 2013 9:10 AM -
see this one: http://www.codeproject.com/Articles/274982/Commands-in-MVVM
Microsoft Certified Solutions Developer - Windows Store Apps Using C#
- Marked as answer by DanieleRM78 Monday, August 5, 2013 12:23 PM
Monday, August 5, 2013 9:34 AM -
Thanks a lot for the suggestion, I found really useful also this article:
http://code.msdn.microsoft.com/windowsapps/Command-binding-inside-3cef5eea
Thanks again.
Bye
Daniele.
Monday, August 5, 2013 12:23 PM