【发布时间】:2009-10-15 21:49:02
【问题描述】:
我想知道在 WPF 中是否能够获取数据模板对象的实际实例。例如以下情况:
<UserControl>
<UserControl.Resources>
<DataTemplate x:Key="MyTemplate">
<CustomControl ></CustomControl>
</DataTemplate>
</UserControl.Resources>
<ListBox DataTemplate="{StaticResource MyTemplate}"></ListBox>
</UserControl>
假设CustomControl 有一个CustomEvent 和一个公共CustomMethod。我想访问该事件和用户控件中的公共方法。这可能吗?我怎么能做到这一点?提前感谢您的帮助。
干杯,
尼禄
【问题讨论】:
-
@itowlson:来自放置 ListBox 的用户控件。我想在事件触发时从用户控件调用自定义方法(包含在 CustomControl 中)。
标签: wpf datatemplate