8,757
社区成员
发帖
与我相关
我的任务
分享
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"));
}
}
}
}