Reputation: 38555
Well the question says it all? I have a DataTemplate with a button is there any way to run a function or some how tell the object that the button was pressed?
Upvotes: 1
Views: 967
Reputation: 24554
Give the button a x:name and you can see that name in the button events 'sender' or e.source parameter
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
Upvotes: 3