且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 WPF 中,如何确定控件所在的网格中的列/行?

更新时间:2021-10-15 03:28:41

在你说的按钮的 Click 事件处理程序中:

In the Click event handler for the button you say:

int row;
Button btn = sender as Button;
if (btn != null)
{
    row = Grid.GetRow(btn); // And you have the row number...
}
else
{
    // A nasty error occurred...
}