一直用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 > Untitled Page </ 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" > ... new agHost("wpfeControl1Host", // hostElementID (HTML element to put WPF/E control into) "wpfeControl1", // ID of the WPF/E ActiveX control we create "400", // Width "400", // Height "white", // Background color null, // SourceElement (name of script tag containing xaml) "Plug.xml", // Source file "false", // IsWindowless "30", // MaxFrameRate null // OnError handler ); </ 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下载