Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
那么问题说明了一切?我有一个带有按钮的 DataTemplate 有什么方法可以运行一个函数,或者如何告诉对象按下了按钮?
给按钮 ax:name ,您可以在按钮事件 'sender' 或 e.source 参数中看到该名称
var source = sender as FrameworkElement; // Or whatever real control it is var parent = source.parent; // Get parent control(s) var dataContext = source.DataContext; // Get databinding context