在silverlight1.1中调用客户端和服务器方法,偶然看到的,和大家分享。顺便散个分。
作者:renyusheng
调用js方法
<Canvas x:Name = "Canval_1" xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<TextBlock x:Name = "txt1" MouseLeftButtonDrow="clientEvent">text test...</TextBlock>
</Canvas>
调用服务器方法
<Canvas x:Name = "Canval_1" xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="SilverlightCSApplication1.Page;assembly=clientbin/SilverlightCSApplication1.dll">
<TextBlock x:Name = "txt1" MouseLeftButtonDrow="serverEvent">text test...</TextBlock>
</Canvas>
注意加粗斜体的那句代码,在调用服务器方法时是必须的。
SilverlightCSApplication1.Page是命名空间.类名
assembly=clientbin/SilverlightCSApplication1.dll 动态链接库文件的路径
在调用客户端方法的时候不能加上面加粗显示的那段代码,不然会报错。
来自:http://silverlight.cn/blogs/renyusheng/archive/2007/10/30/silverlight1-1.aspx