silverlight - 如何更改 Silverlight for Windows Phone 上 Web 浏览器上的 ComboBox "selectedIndex"?

标签 silverlight windows-phone-7 combobox browser selectedindex

在 Web 浏览器中,有此页面 ( http://gttweb.5t.torino.it/gtt/en/percorsi/percorsi-ricerca.jsp ),并且有“destinationCity”ComboBox。在 VB.NET 中我使用:

Dim DestinationComboBox As HtmlElement = MainWebBrowser.Document.All.Item("destinationCity")
DestinationComboBox.SetAttribute("selectedindex", 1)

更改 ComboBox selectedIndex,但在 Silverlight 中(在此 WebBrowser 中),只有 InvokeScript 函数。如何使用 InvokeScript( )? 我试过了

InvokeScript("eval", "document.getElementById('destinationCity').selectedindex = 4")

但它不起作用..请帮忙!

最佳答案

如果您使用 Chrome 开发者工具或 FireBug 对给定页面执行以下 JavaScript,您会发现它在桌面浏览器中不起作用:

document.getElementById('destinationCity').selectedindex = 4

JavaScript 和 selectedIndex 属性区分大小写。作品如下:

document.getElementById('destinationCity').selectedIndex = 4

关于silverlight - 如何更改 Silverlight for Windows Phone 上 Web 浏览器上的 ComboBox "selectedIndex"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12185943/

相关文章:

wpf - 从 ObservableCollection 添加或删除项目时列表框不更新

当组合框获得焦点时,JavaFX 组合框不选择所有文本

c# - 特定类型的 List<T> 导致 ComboBox 中断

c# - 一次一个地将作业分配给 BackgroundWorker 线程

silverlight - 在 Silverlight 拖放中获取放置索引

silverlight - 使用 MVVM 模式实现 Telerik VirtualQueryableCollectionView

c# - 想在 WP7 应用程序中单击和双击图像

c# - 如何在 Windows Phone 7 中滑动

c# - 无法清除组合框中的选择

c# - Silverlight Xaml 中的 ComboBox IsEnabled 绑定(bind)问题