wpf how to find a canvas inside a grid in a specific Row/column
i have a grid divided into several rows/columns, how can i get the canvas that's inside that grid in (x,y) fo开发者_如何学Cr example how can i get the canvas which is inside the row 2 column 1 ?
Thanks a lot
There can be multiple elements in a "cell", there probably is no nice way to do this, i would use a query like this:
int x = 0;
int y = 1;
var target = (from UIElement c in grid.Children
where Grid.GetRow(c) == y && Grid.GetColumn(c) == x
select c).First();
building on H.B's solution, i'd add a small test on the "Canvas" part of the question:
int x = 0;
int y = 1;
var target = (from UIElement c in grid.Children
where Grid.GetRow(c) == y && Grid.GetColumn(c) == x && c is Canvas
select c).First();
精彩评论