tags:

views:

125

answers:

0

I have a WPF Grid with some rows and columns, e.g.

<Grid Name="myGrid" MouseMove="OnMouseMove">
    <Grid.RowDefinitions>
     <RowDefinition/>
     <RowDefinition/>
     <RowDefinition/>
    </Grid.RowDefinitions>

    <Grid.ColumnDefinitions>
     <ColumnDefinition/>
     <ColumnDefinition/>
     <ColumnDefinition/>
    </Grid.ColumnDefinitions>
</Grid>

With some a handler for MouseMove in the .cs file, e.g.

private void OnMouseMove(object sender, MouseEventArgs e)
{
    var position = e.GetPosition(myGrid);

    // What row & col is the mouse over?
}

I want to be able to find which row and column in the grid the mouse is over, is this possible?

[Note: this is a simplified version of the problem, so it looks a little odd to present it in this way - it's part of some drag & drop between grids functionality]