下面是我更新Silverlight ctp到Silverlight beta 1.0的一个纪录,希望对各位同学有帮助。
1、卸载Silverlight ctp 和sdk以及VS template
2、安装Silverlight Beta 1.0 (
[url]http://www.microsoft.com/silverlight/install.aspx[/url]).
3、安装Microsoft Silverlight 1.0 Beta SDK (
[url]http://go.microsoft.com/fwlink/?linkid=89144&clcid=0x409[/url]).同时安装 VS template
4、从C:\Program Files\Microsoft SDKs\Silverlight1.0SDK file from拷贝 Silverlight.js替换aghost.js :
<script type="text/javascript" src="
Silverlight.js"></script>
5、用Sys.Silverlight.createObject() 替换aghost(). 调用参数也作了相应修改:
WPF/E: new agHost(
"WpfeControlHost", // DIV tag id.
"WpfeControl", // WPF/E control id.
"400px", // Width of rectangular region of WPF/E control in pixels.
"100px", // Height of rectangular region of WPF/E control in pixels.
"#D6D6D6", // Background color of rectangular region of WPF/E control.
null, // SourceElement property value.
"HelloWorld.xaml", // Source property value.
"false", // WindowlessMode property value.
"30", // MaxFrameRate property value.
'myErrorHandler'); // OnError property value -- notice use of single quotes.
"WpfeControlHost", // DIV tag id.
"WpfeControl", // WPF/E control id.
"400px", // Width of rectangular region of WPF/E control in pixels.
"100px", // Height of rectangular region of WPF/E control in pixels.
"#D6D6D6", // Background color of rectangular region of WPF/E control.
null, // SourceElement property value.
"HelloWorld.xaml", // Source property value.
"false", // WindowlessMode property value.
"30", // MaxFrameRate property value.
'myErrorHandler'); // OnError property value -- notice use of single quotes.
Silverlight:
Sys.Silverlight.createObject( "HelloWorld.xaml", // Source property value. WpfeControlHost, // DOM reference to hosting DIV tag. "WpfeControl", // Unique control id value. { // Control properties. width:'400', // Width of rectangular region of control in pixels. height:'100', // Height of rectangular region of control in pixels. inplaceInstallPrompt:false,// Determines whether to display in-place install prompt if invalid version detected. background:'#D6D6D6', // Background color of control. isWindowless:'false', // Determines whether to display control in Windowless mode. framerate:'30', // MaxFrameRate property value. version:'0.9' // Control version to use. }, { onError:'myErrorHandler', // OnError property value -- event handler function name. onLoad:null // OnLoad property value -- event handler function name. }, null); // Context value -- event handler function name.
一些参数和参数的顺序都发生了变化。首先Div tag的没有引号的. 其次只要传递五个参数,第四、五个参数是个javascript object有多个参数。
Tips
1、搜索Xaml文件,去除所有的javascript实例,这个修改主要是现在Silverlight支持多种语言了,不仅仅是Javascript,而Xaml只是描述界面的。
例如:
<Canvas xmlns="
[url]http://schemas.microsoft.com/client/2007[/url]"
xmlns:x=" [url]http://schemas.microsoft.com/winfx/2006/xaml[/url]"
Loaded="javascript:root_Loaded"
x:Name="root"
……
xmlns:x=" [url]http://schemas.microsoft.com/winfx/2006/xaml[/url]"
Loaded="javascript:root_Loaded"
x:Name="root"
……
</Canvas>
替换成
<Canvas xmlns="
[url]http://schemas.microsoft.com/client/2007[/url]"
xmlns:x=" [url]http://schemas.microsoft.com/winfx/2006/xaml[/url]"
Loaded="root_Loaded"
x:Name="root"
……
xmlns:x=" [url]http://schemas.microsoft.com/winfx/2006/xaml[/url]"
Loaded="root_Loaded"
x:Name="root"
……
</Canvas>
2、事件
MouseMove event 作了些修改. 获取x、y坐标现在改成了: args.GetValue("X")
3、
CreateFromXaml method 已经不是Silverlight control object 的, 属于 content object. 因此要wpfeControl.
content.createFromXaml("...").替换 wpfeControl.createFromXaml("...")
4、先看看这两篇文章
What's New in Silverlight (1.0 Beta and 1.1 Alpha)? 、
New API for the Silverlight 1.0 Beta.
5、MIX07会议中微软同时发布Silverlight 1.0的Beta测试版与Silverlight 1.1的Alpha测试版。1.0 Beta版已提供Go Live授权,1.1版本还是Alpha,功能虽然强大很多,但是风险挺大。企业用Silverlight 1.0测试版开发产品,可直接上线使用。2007年夏天微软将发布1.0正式版。
本文转自 张善友 51CTO博客,原文链接:http://blog.51cto.com/shanyou/74293,如需转载请自行联系原作者