简体   繁体   English

如何使用 Javascript 找到 Silverlight 网格的第 n 个子元素?

[英]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:我想简单地 select Silverlight 网格的第 n 个子元素,使用 Javascript,如下所示:

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.我试过猜测:grid.getChild()、grid.getChild(n)、grid.child[n]、grid.children[n].. 这些似乎都不存在。

So, simply, what method do I have to use to get the nth child element?那么,简单地说,我必须使用什么方法来获取第 n 个子元素?

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. 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. Silverlight 中的可视元素树未暴露给 JavaScript。 It is internal for good reason.它是内部的,有充分的理由。 That would expose Silverlight to JavaScript-based hacking.这会将 Silverlight 暴露给基于 JavaScript 的黑客攻击。

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 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.您使用 [ScriptableType] 属性标记您希望向 Javascript 公开的类,并使用[ScriptableType] [ScriptableMember]标记您希望调用的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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