简体   繁体   English

DataTemplate与wp7 silverlight中的按钮

[英]DataTemplate with button in wp7 silverlight

I writing wp7 silverlight app. 我写的是wp7 silverlight app。 I have a listbox with items. 我有一个包含项目的列表框。 I want each item to have different DataTemplate. 我希望每个项目都有不同的DataTemplate。 I'm using OnContentChanged event and read the template to the ContentTemplate. 我正在使用OnContentChanged事件并将模板读取到ContentTemplate。 My problem is with buttons on the template. 我的问题是模板上的按钮。 On runtime the buttons event handler is not found, and I get exception. 在运行时,找不到按钮事件处理程序,我得到异常。 What can I do? 我能做什么?

最简单的方法是(为每个项目使用不同的DataTemplate)是实现某种DataTemplateSelector。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM