第一个WPF-E

一直用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下载 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值