silverlightdatagridmouseleftbuttondown

Get row selected index value in Mouse Left Button Down in Silverlight


I have an image in a datagrid that shows below

<sdk:DataGridTemplateColumn x:Name="colStat" IsReadOnly="True" Header="Stat" Width="60" CanUserResize="False">
 <sdk:DataGridTemplateColumn.CellTemplate>
    <DataTemplate>
       <StackPanel x:Name="spStats" VerticalAlignment="Center" Margin="10,0,0,0"         Width="Auto" Height="Auto" HorizontalAlignment="Center" Orientation="Vertical" Cursor="Hand">             
           <Image x:Name="imgStats" Source="Assets/Images/stats.png" Height="25" Width="25" 
               Margin="0" MouseLeftButtonDown="imgStats_MouseLeftButtonDown" MouseLeftButtonUp="imgStats_MouseLeftButtonUp" />
        </StackPanel>
     </DataTemplate>
   </sdk:DataGridTemplateColumn.CellTemplate>
  </sdk:DataGridTemplateColumn>

I have two events as mentioned in my code MouseLeftButtonDown And MouseLeftButtonUp for the image,I can able to get my row selected index value in MouseLeftButtonUp but i couldn't able get selected index value in MouseLeftButtonDown. I need the Selected Index value in MouseLeftButtonDown also. Can anyone please help me solve this issue.

Neon


Solution

  • There is a sample , just change 'mousemove' to 'mouseleftbuttondown'

    Try This