c# - Grid to array[][] or finding items in each cell -


i have grid 3x3 contains 9 images. possible convert images array[][], or loop through every cell of grid?

the point in every of 9 cells have 1 image. want know image in specific cell.

edit

here xaml code create cells on layout

<grid x:name="map">         <!-- row , coulmns definition -->         <grid.rowdefinitions>             <rowdefinition height="120"/>             <rowdefinition height="120"/>             <rowdefinition height="120"/>             <rowdefinition height="120"/>         </grid.rowdefinitions>         <grid.columndefinitions>             <columndefinition width="200"/>             <columndefinition width="200"/>             <columndefinition width="200"/>             <columndefinition width="0"/>             <columndefinition width="128*" />         </grid.columndefinitions>          <!-- canvas & components  -->          <canvas         x:name="mycanvas"         background="azure"         grid.columnspan="3"         grid.rowspan="3">         </canvas>         <button background="chocolate" content="spin" name="spinbutton" grid.row="3" grid.column="3" click="spinbutton_click" grid.columnspan="2" margin="15,36,12,12" />     </grid> 

i everyting in c# code behid. animating images using storyboard class , set 9 images specific positions ( every image in each of 9 cells ) . code tried change image frameworkelement anyway sees canvas element. maybe there option take elements specific coordinates?

adding images c#:

 public list<image> setimages(string order)         {             list<image> line = new list<image>();              (int = 0; < imagesqty; i++)             {                 image img1 = new image();                 img1.source = ananasimage;                 img1.stretch = stretch.fill;                 img1.width = 200;                 img1.height = 120;                 if (order.equals("left"))                 {                     line.add(img1);                     canvas.settop(img1, -200);                     canvas.setleft(img1, 0);                     mycanvas.children.add(img1);                 }                 else if (order.equals("middle"))                 {                     line.add(img1);                     canvas.settop(img1, -200);                     canvas.setleft(img1, 180);                     mycanvas.children.add(img1);                 }                  else if (order.equals("right"))                 {                     line.add(img1);                     canvas.settop(img1, -200);                     canvas.setleft(img1, 360);                     mycanvas.children.add(img1);                 }              }              return line;         } 

you can use children property of grid enumerate child controls. also, can use grid.getrow , grid.getcolumn methods know on row/column control is. there, it's matter of stiching bits together:

int row = 3; int column = 2;  var image = grid.children.oftype<image>().firstordefault(i => grid.getrow(i) == row && grid.getcolumn(i) == column);  if (image != null) {     // found picture on line 3 , column 2 } 

also, if want know in line/column images are, need add them grid in first place:

if (order.equals("left")) {     line.add(img1);     grid.setcolumn(img1, 0);     grid.setline(img1, 0);     map.children.add(img1); } else if (order.equals("left")) {     line.add(img1);     grid.setcolumn(img1, 1);     grid.setline(img1, 0);     map.children.add(img1); } // , on 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -