简体   繁体   中英

How to find the nth child element of a Silverlight Grid, using Javascript?

I have been looking around for this on Google but I have not yet found a good result.

I would like to simply select the nth child element of a Silverlight Grid, using Javascript, like this:

for (var i = 0; i < grid.children.count; i++) {
    if (grid.getChild[i]['Grid.Row'] == rowIndex
        && grid.getChild[i]['Grid.Column'] == columnIndex) {
            //DoSomething();
            break;
    }
}

I have tried guessing: grid.getChild(), grid.getChild(n), grid.child[n], grid.children[n].. none of those appear to exist.

So, simply, what method do I have to use to get the nth child element?

ps: I have been trying to search for the Silverlight API online (pretty much like Java has the javadoc reference with over 14.000 pages of each class and its method..), but no success. If anyone knows where it is, I'd be glad to know.

Thanks

The visual element tree in Silverlight is not exposed to JavaScript. It is internal for good reason. That would expose Silverlight to JavaScript-based hacking.

You can however expose methods in your Silverlight application to Javascript, so I would suggest creating a C# method in your Silverlight app to return, or alter, specific elements in the Visual Tree and call that from Javascript instead.

You mark classes you wish to expose to Javascript with the [ScriptableType] attribute and methods you wish to call with the [ScriptableMember] attribute.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM