views:

486

answers:

1

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?

+3  A: 

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
TFD
Ok so far so good but that did not solve my problem :P, i get to .net code but how do i get the Object that the datatemplate is for? in my case Job
Petoj
nvm button.DataContext solved it! thank you
Petoj