阅读教程

Silverlight2.0入门教程(八): 使用WPF创建Digg桌面应用程序

[日期:2008-06-02] 来源:  作者:志伟
Silverlight2.0入门教程(八): 使用WPF创建Digg桌面应用程序,本文讲述了如何使用WPF创建Silverlight2.0桌面应用程序.欢迎在线阅读Silverlight2.0教程

Creating a Digg Desktop Application using WPF

This is part eight of eight tutorials that walk through how to build a simple Digg client application using the Beta1 release of Silverlight 2.  These tutorials are intended to be read in-order, and help explain some of the core programming concepts of Silverlight. Bookmark my Silverlight 2 Reference page for more of Silverlight posts and content. 

<Download Code> Click here to download a WPF version of this Digg client sample. </Download Code>

Creating a Digg Desktop Application Using WPF

Our goal with this last tutorial is a little different than the previous seven tutorials.  We actually aren't going to be running code in Silverlight with this tutorial - instead we will be using WPF and .NET 3.5.  We'll be taking the existing Digg application code we've written to run inside Silverlight in the browser, and re-use it to also run as a Windows desktop application.

Silverlight ships with a compatible API subset of what is in the full version of the .NET Framework.  One goal with this is to enable developers to learn a common programming model and tool-set and be able to re-use skills, code and content across RIA web applications, rich Windows desktop applications, and Office solutions.

Below are the steps I took to re-use our existing Digg Silverlight application code (which runs in the browser) to build a Windows desktop application version (which runs outside the browser).

Step 1: Create a New WPF Desktop Application

We'll start by creating a new WPF Desktop Application using VS 2008.  We'll name it "DiggDesktopSample":

Silverlight2 WPF入门

This will create a project inside VS with two files - an App.xaml, and a Window.xaml:

Silverlight2 WPF入门

Note that this project structure is very similar to the Silverlight one we created in Tutorial 1 of this series (which had an App.xaml and a Page.xaml file).

Step 2) Copy Existing Digg Application Code into the WPF Application

We'll copy/paste our existing DiggApplication Silverlight code into our new DiggDesktopSample Windows project:

Silverlight2 WPF入门

Currently in Beta1 this copy/paste effort is a manual step - we will eventually have a more automated way to move the code between project types.

Step 3) Fix Up a Few Issues

I had to make two changes to get our existing Digg sample code to compile:

1) The Silverlight Beta1 XAML schema xmlns: URL is different than the full WPF desktop version.  I needed to tweak the XAML files I copied into the new project to point to the full WPF schema.  This is something we are looking to improve before we ship.

2) I had to change the <WaterMarkTextBox> control to <TextBox> and change the <HyperlinkButton> control to be a <TextBlock>.  These are two controls that are new in Silverlight Beta1 that aren't in the full WPF yet (we will add them in the future though).  I did not have to change any of the code that worked with these controls, though, nor my network, LINQ to XML, nor databinding code.

Once I made these small tweaks the project compiled clean.



[1] [2] 下一页   
      
阅读:
录入:志伟

评论 】 【 推荐 】 【 打印
上一篇:Silverlight2.0入门教程(七): 使用控制模板自定义外观和触觉
下一篇:Silverlight2 超酷体验.[原创]
本文评论       全部评论
发表评论


点评: 字数
姓名:

 
搜一下


 
本周热门教程
 

关于我们 | 广告合作 | 法律声明 | 联系站长 | 网站地图 | 网站搜索 | | Top ↑
Copyright © 志伟教程资料网 Powered by zhiweinet 1.0
 本栏目提供:Silverlight2.0入门教程(八): 使用WPF创建Digg桌面应用程序