【发布时间】:2017-07-26 00:18:17
【问题描述】:
我正在尝试将我的 wpf 项目中定义的数组传递给 Webbrowser 控件中加载的 html 页面内的 javascript 函数,但我找不到任何方法。
我想做的例子:
Xaml:
<WebBrowser x:Name="WBTimeGraph" />
c#:
namespace GraphNameSpace
{
public partial class TimeGraph : Window
{
// MEMBERS
public []int MyArrayOfData = new int[50];
// METHODS
public TimeGraph ()
{
InitializeComponent();
string Dir = Environment.CurrentDirectory;
Uri tNav = new Uri(Dir + string.Format("/TimeGraph.html"));
WBTimeGraph.Navigate(tNav);
}
}
}
HTML:
<script>
$(function () {
// Do a Graph with MyArrayOfData
});
</script>
【问题讨论】:
-
您不能调用返回上述值的方法?
-
我不想调用方法,我只需要在javascript函数中使用“ValueThaWillBeUsesByTheJavascriptFunction”
-
您可以在指定 TimeGraph.html 时在查询字符串中传递数据,如果它不是太大的话。否则我会创建 HTML 文件的副本,注入数据,然后打开它。
-
谢谢丹,好主意:)
标签: javascript c# html wpf webbrowser-control