c# - Identifying class instances created without any variable name -
i going program windows phone app in c# , xaml. have created usercontrol called boxcontrol. means can create variables type.
i create instances of control in nested loop, seen below. problem when create instances of control way have done it, how reference them in code later? how uniquely identify each instance?
// = column, j = row (int i=0; i<4; i++) { (int j = 0; j < 3; j++) { boxlist.add(new boxcontrol()); grid.setcolumn(boxlist[(i*3)+j], i); grid.setrow(boxlist[(i*3)+j], j); boxgrid.children.add(boxlist[(i*3)+j]); boxlist[(i * 3) + j].addhandler(uielement.tapevent, new eventhandler<gestureeventargs>(boxcontrol_tap), false); } }
for instance, if tap 1 of them on screen, specific control. have added handlers that, can't reference object. hope can help...
not sure windows phone-app eventhandler, wpf , windows form give "sender" of event. in case, particular boxcontrol tapped, need cast it.
referencing outside of event matter of math, doing within for-loop.
Comments
Post a Comment