我有一个网格,我知道用鼠标单击的位置的 X 值和 Y 值。
示例:X: 235, Y: 235 --> 这应该是 Column: 3 and Row: 3
如何获取 x,y 坐标上的列和行?
我真的需要添加行/列的每个宽度直到达到所需的 x/y 值吗?
我正在使用 WPF(用于我的网格)和 C#(用于 x 和 y 位置)
谁能帮我解决这个问题?
最佳答案
Math.Floor 函数,例如:
Math.Floor(235/scale)
where scale is the the width or height of the grid cell.
定义: 返回小于或等于指定数字的最大整数。 Math.ceil 则相反。
关于wpf - 从 X 和 Y 位置获取网格行和列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11116595/