一直用WPF作项目,直到最近才研究WPF-E,今天用了下,发觉这个EveryWhere还真的Web气味十足.
好吧,下手写写:
1.写一个(插件)XMAL文件
<
Canvas
xmlns
="http://schemas.microsoft.com/client/2007"
xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml"
>
<
Canvas
x:Name
="mainUI"
Width
="200"
Height
="200"
Background
="YellowGreen"
Opacity
="0.6"
Loaded
="javascript:root_mainLoaded"
>
<
Ellipse
x:Name
="ellipse"
Width
="20"
Height
="20"
Fill
="Gray"
Loaded
="javascript:root_Loaded"
></
Ellipse
>
</
Canvas
>
</
Canvas
>
2.写一个页面调用XMAL
<
html
xmlns
="http://www.w3.org/1999/xhtml"
>
<
head
>
<
title
>
UntitledPage
</
title
>
<
script
type
="text/javascript"
src
="js/aghost.js"
></
script
>
<
script
type
="text/javascript"
src
="js/eventhandlers2.js"
></
script
>
</
head
>
<
body
>
<
form
>
<
div
id
="wpfeControl1Host"
>

<
script
type
="text/javascript"
>
...
newagHost("wpfeControl1Host",//hostElementID(HTMLelementtoputWPF/Econtrolinto)
"wpfeControl1",//IDoftheWPF/EActiveXcontrolwecreate
"400",//Width
"400",//Height
"white",//Backgroundcolor
null,//SourceElement(nameofscripttagcontainingxaml)
"Plug.xml",//Sourcefile
"false",//IsWindowless
"30",//MaxFrameRate
null//OnErrorhandler
);
</
script
>
</
div
>
</
form
>
</
body
>
</
html
>
3.写元素事件(JS)文件
涉及要点:
(1).mainUI = sender.findName("mainUI"); 从事件参数李得到元素
(2).mainUI.mouseLeftButtonUp ="javascript:handleMouseUp"; 给元素追加事件
(3). ellipse["Canvas.Left"] = 0; 设置Canvas.Left属性
(4). sx = eventArgs.x; 从事件参数里得到坐标值
总体来说,目前的WPF-E还是比较"笨重"的,WPF的逻辑操作转为JS,工作量,维护调试都是个问题.期待能有托管代码的版本推出.
最后,DEMO下载