c# - children of object -
i have function supposed homecoming uielementcollection. function takes in uielement has children property (i.e. stackpanel, grid, etc.) not know uielement is, store general object.
public uielementcollection retcol (object givenobject){ ... } i want homecoming children of givenobject, can't find way besides casting givenobject stackpanel or grid.
is there way can children property of givenobject?
stackpanel , grid both inherit panel, alter method to:
public uielementcollection retcol (panel givenobject){ homecoming givenobject.children; } or if want create available uielement types create more general , check type in function:
public uielementcollection retcol (uielement givenobject){ if(givenobject panel) homecoming ((panel)givenobject).children; else if(givenobject someothercontainer) homecoming ((someothercontainer)givenobject).children; else homecoming null; } c# uielementcollection
No comments:
Post a Comment