silverlight与JavaScript交互,WebApplication在哪里?

senr0816 2010-03-16 03:09:55
RT,找不到WebApplication啊,使用WebApplication.Current.RegisterScriptableObject后,
显示:找不到类型或命名空间名称“WebApplication”(是否缺少 using 指令或程序集引用?)
请问如何才能使用这个类啊~
...全文
136 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
jv9 2010-03-18
  • 打赏
  • 举报
回复
WebApplication是Javascript对象成员,没有被封装到.net framework,所以没有命名空间。
使用[Scriptable]属性,说明他一个 Scriptable成员。
senr0816 2010-03-17
  • 打赏
  • 举报
回复
我后面用了HtmlPage.RegisterScriptableObject("Page", this);就好了
请问WebApplication是哪个命名空间的,我怎么找不到?
jv9 2010-03-17
  • 打赏
  • 举报
回复
使用 [Scriptable] 属性了么?

试试这样写代码:



using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Browser;

namespace ClientSideAndServerSide {

[Scriptable]
public class EventArgs<T> : EventArgs {
private T _data;

public EventArgs(T args) {
_data = args;
}

[Scriptable]
public T Data {
get {
return _data;
}
}
}

[Scriptable]
public partial class Page : Canvas {


[Scriptable]
public event EventHandler CallbackToBrowser;

public void Page_Loaded(object o, EventArgs e) {
// Required to initialize variables
InitializeComponent();
WebApplication.Current.RegisterScriptableObject("EntryPoint", this);
this.MouseLeftButtonDown += new MouseEventHandler(Page_MouseLeftButtonDown);
}

void Page_MouseLeftButtonDown(object sender, MouseEventArgs e) {
if (CallbackToBrowser != null) {
CallbackToBrowser(this, new EventArgs<string>("my value"));
}
}
}
}


8,757

社区成员

发帖
与我相关
我的任务
社区描述
WPF/Silverlight相关讨论
社区管理员
  • WPF/Silverlight社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧