java
css
c
python
ruby-on-rails
mysql
objective-c
multithreading
eclipse
html5
facebook
oracle
tsql
apache
mvc
asp
api
jsp
postgresql
dom
Are you setting e.Handled to true in you event handler per chance? If so then the data grid will not see the mouse down event.
e.Handled
true
This question is kind of old, so I'm not sure if you have the answer or not, but what you can do is set some sort of identifier in the 'tag' property of the image that you can use to identify the row (or more precisely the object bound to the row) that the click is coming from. I'm assuming that you are binding some sort of object from a collection to the row and that the 'sender' is of type 'image' in your event.
<data:DataGridTemplateColumn.CellTemplate> <DataTemplate> <Image Width="20" Stretch="Fill" Name="Delete" Source="/Portal;Component/Images/Delete.png" MouseLeftButtonDown="ImageDelete_MouseLeftButtonDown" Tag="{Binding Id}"/> </DataTemplate> </data:DataGridTemplateColumn.CellTemplate>
Now you can access the id of object that is bound to the row that was clicked, like so... (in VB)
Private Sub ImageDelete_MouseLeftButtonDown(sender As System.Object, e As System.Windows.Input.MouseButtonEventArgs) Dim img As Image = TryCast(sender, Image) Dim id As Integer = CInt(img.Tag) ' Do stuff with id End Sub
in C#:
Private void ImageDelete_MouseLeftButtonDown(System.Object sender, System.Windows.Input.MouseButtonEventArgs e) { Image img = sender as Image; int id = Convert.ToInt32(img.Tag); // do stuff with id }
code here