【问题标题】:Fire a template child event in current context?在当前上下文中触发模板子事件?
【发布时间】:2010-02-03 11:23:59
【问题描述】:

有没有办法在当前上下文(即页面、窗口、用户控件等)中从 DataTemplate 中的视觉对象触发事件。

例如,我有一个包含按钮或列表框的 DataTemplate。我希望当单击按钮或在 ListBox 中触发 ListBox.SelectionChanged 时,应在包含使用此 DataTemplate 的 ControlControl 的页面上声明事件处理程序。

有什么想法吗?

【问题讨论】:

    标签: wpf datatemplate event-handling eventsetter


    【解决方案1】:

    使用RoutedCommands。

    【讨论】:

      猜你喜欢
      • 2015-06-02
      • 2018-04-01
      • 2013-08-23
      • 2014-06-29
      • 1970-01-01
      • 2011-08-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多