【发布时间】:2013-01-18 09:34:55
【问题描述】:
我使用位于 stackoverflow:event-fired-when-item-is-added-to-listview 的解决方案来利用 CodeBehind 中的接口 INotifyCollectionChanged。有没有办法在 XAML 中添加这个 EventHandler?
本质上,我希望在 XML 中定义这一行:
((INotifyCollectionChanged)lbFiles.Items).CollectionChanged += lbFiles_SelectionChanged;
【问题讨论】:
-
您是否在实现自己的 GUI 元素?通常,您将元素的 ItemsSource 属性绑定到可观察的集合,然后事情就会亮起来。
标签: c# wpf events user-interface event-handling