Greetings,
I’m having a Grid to which I add rows and columns according to data given by the user.
Now I wish to have a event that captures the location of my mouseclick by row and column.
So when I click in column 5 of row 2 I wish to get exactly that information in my code behind.
However all I’m getting so far is args.OriginalSource = {System.Windows.Controls.Grid}
Is there any way to accomplish this?
Xaml:
<Grid Background="White" x:Name="MainSchedular">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="33" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="33">
<ColumnDefinition Width="33">
<ColumnDefinition Width="33">
</Grid>
Code behind:
this.MouseLeftButtonDown += (se, eas) =>
{
//some code here that captures the row and column position
};
In case people are wondering how:
I’ve managed to do this by creating a button and placing in the top left corner of the Grid.
Using this button as reference for MouseButtonEventsArgs.GetPosition I can then calculate which row and column I clicked by: