Download presentation
Presentation is loading. Please wait.
1
使用WPF创建Windows应用和Web应用
2
课程内容概述 课程讲解如何使用WPF的数据管理、托管和UI来创建丰富的客户应用,演示Windows应用及基于浏览器应用如何使用这些服务。讨论应用使用标准窗体和基于浏览器各自的优势及适用场景。
3
课程内容安排 WPF介绍 应用的生命周期管理 用户体验模型 Hosting
4
4/24/2019 6:18 PM WPF介绍 4 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
5
WPF 架构 XPS Viewer Managed Unmanaged Windows Presentation Foundation 5
Application Services Deployment Services Databinding USER INTERFACE SERVICES XAML Accessibility Property System Input & Eventing BASE SERVICES DOCUMENT SERVICES Packaging Services XPS Documents Animation 2D 3D Audio Imaging Text Video Effects Composition Engine MEDIA INTEGRATION LAYER Controls Layout Windows Presentation Foundation XPS Viewer Property Engine Input / Eventing System .NET Framework 2.0 Desktop Windows Manager Media Integration Layer DirectX Windows Vista Display Driver (LDDM) Windows Media Foundation Composition Engine Print Spooler Managed Unmanaged 5
6
使用XAML,设计人员与开发人员可以更好地协作。
设计与开发 使用XAML,设计人员与开发人员可以更好地协作。 设计人员设计UI 开发员添加业务功能 6
7
XAML = Extensible Application Markup Language
易于使用,声明标记 代码与内容分离 可用于Web应用和windows应用。 <Button Width="100"> OK <Button.Background> LightBlue </Button.Background> </Button> XAML Button b1 = new Button(); b1.Content = "OK"; b1.Background = new SolidColorBrush(Colors.LightBlue); b1.Width = 100; C# Dim b1 As New Button b1.Content = "OK" b1.Background = New _ SolidColorBrush(Colors.LightBlue) b1.Width = 100 VB.NET 7
8
Hello WFP
9
4/24/2019 6:18 PM 应用的生命周期管理 9 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
10
Applications in WPF 应用级的考虑
4/24/2019 6:18 PM Applications in WPF 应用级的考虑 如何管理应用生命周期的活动 如何管理多次会话中的状态 用户如何与应用进行交互 平台是否能构建一个用户体验模型 应用是基于windows还是基于浏览器的 基于windows应用和浏览器应用在用户体验上的不同 他们安全吗? 10 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
11
应用的生命周期 如何管理应用生命周期的活动
4/24/2019 6:18 PM 应用的生命周期 如何管理应用生命周期的活动 Application类管理所有的应用生命周期中的活动 Startup, activation, deactivation, shutdown, session ending, error handling 为进程提供一个托管的抽象层 可以忽视主方法、退出代码、以及WM_* 消息 支持定制 用于保持应用的状态 11 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
12
x:Class=“MyFirstApp.MyApp" xmlns:x=
// application.xaml <Application x:Class=“MyFirstApp.MyApp" xmlns:x= " xmlns= " ShutdownMode=“OnLastWindowClosed” Startup=“StartupHandler” SessionEnding=“SessionEndingHandler” StartupUri=“window1.xaml” /> // application.xaml <Application x:Class=“MyFirstApp.MyApp" xmlns:x=" xmlns=" /> // application.xaml.cs namespace MyFirstApp { partial class MyApp : Application public MyApp() InitializeComponent(); Window win = new Window(); win.Show(); } using System; using System.Windows; namespace MyFirstApp { static class Program [STAThread] static void Main() MyApp app = new MyApp(); app.Run(); } class MyApp : Application MyApp() Window win = new Window(); win.Show(); 12 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
13
管理多次会话中的状态 如何保存设置与用户数据?
4/24/2019 6:18 PM 管理多次会话中的状态 如何保存设置与用户数据? 文件系统 Fully-trusted applications only 注册表 Generally not recommended 配置管理器 Machine, user, or app-wide state 隔离存储 Full or partially-trusted applications 512 KB limit in Internet Zone Cookies Interop with web backend 13 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
14
4/24/2019 6:18 PM 用户体验模型 14 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
15
用户体验模型 用户如何与应用进行交互? MDI SDI / Dialog Structured Navigation
4/24/2019 6:18 PM 用户体验模型 用户如何与应用进行交互? MDI SDI / Dialog Structured Navigation Navigation-based MDI Navigation-based SDI 15 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
16
用户体验模型 如何选择UI? 专业用户会感被限制,固化。 专业用户会得心应手。 便于初学者学习使用。
4/24/2019 6:18 PM 用户体验模型 如何选择UI? 专业用户会感被限制,固化。 专业用户会得心应手。 使用频率 用户控件程度 便于初学者学习使用。 初学者会不知所措,迷失方向。 16 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
17
用户体验模型 Dialog-Based SDI
4/24/2019 6:18 PM 用户体验模型 Dialog-Based SDI 使用窗口、对话框和控件 一个进程中可能会有多个顶级窗口 软件功能通过菜单展现给用户 // Window1.xaml <Window x:Class=“App.Window1” ...> <DockPanel> <Menu> <!-- define menu here --> </Menu> <!-- controls and UI here --> </DockPanel> </Window> 常用于简单或频繁的任务 用户受到一定限制 17 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
18
用户体验模型 Basic Navigation
4/24/2019 6:18 PM 用户体验模型 Basic Navigation // Page1.xaml <Page x:Class=“App.Page1” ...> <TextBlock> <Hyperlink NavigateUri=“page2.xaml”>Go To Page 2</Hyperlink> </TextBlock> </Page> // Page2.xaml <Page x:Class=“App.Page2” ...> <TextBlock>This is Page 2 使用页面、超链接、框架 可以在浏览器用使用。 提供导航功能 适用于有多个步骤的任务或没有经验的用户。 通过导航和向导,用户可以使用软件功能。 18 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
19
用户体验模型 Problems with simple navigation
4/24/2019 6:18 PM 用户体验模型 Problems with simple navigation Hyperlink == GOTO 19 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
20
用户体验模型 Solving the problems using structured navigation
4/24/2019 6:18 PM 用户体验模型 Solving the problems using structured navigation PageFunctions == function calls 20 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
21
用户体验模型 Structured Navigation
4/24/2019 6:18 PM 用户体验模型 Structured Navigation // PF1.xaml <PageFunction x:Class=“App.PF1” xmlns:sys=“clr-namespace:System; assembly=“mscorlib” x:TypeArguments=“Int32” ...> <Grid> ... </Grid> </PageFunction> // Page1.xaml.cs PF1 pf = new PageFunction1(); pf.InitializeComponent(); pf.Return += new ReturnEventHandler<int>(pf_Return); this.NavigationService.Navigate(pf); 使用 PageFunction PageFunction可以象函数一样被调用,并返回结果给调用者 一旦调用结束,会返回到调用页面 可以创建灵活的页面关系。 适用于复杂的,多变的导航要求 应用驱动用户 21 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
22
4/24/2019 6:18 PM Hosting 22 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
23
Hosting 基于Windows,还是基于浏览器?
4/24/2019 6:18 PM Hosting 基于Windows,还是基于浏览器? 两种常见的WPF的 hosting: Standalone XBAP Hosting在浏览器中不仅是技术问题,还是一个用户体验问题。 Hosting与部署方式相关。 23 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
24
Standalone WPF Applications
4/24/2019 6:18 PM Standalone WPF Applications 需安装 在开始菜单及添加/移除程序中可见 可以使用ClickOnce或MSI进行部署 在单独的窗体中运行 可以在线和离线工作 在线时可以检查是否有更新 完全信认 安装是有是否信认的提示 24 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
25
WPF In Windows
26
Web应用的挑战 Web应用在编程模式上有很大的不同 创建高交互性和高个性化的Web应用有一定的难度 Web应用往往需要平衡交互性和安全。
4/24/2019 6:18 PM Web应用的挑战 Web应用在编程模式上有很大的不同 创建高交互性和高个性化的Web应用有一定的难度 Web应用往往需要平衡交互性和安全。 26 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
27
XAML Browser Applications (XBAPs) 在Web中使用WPF
4/24/2019 6:18 PM XAML Browser Applications (XBAPs) 在Web中使用WPF 不需要安装 在开始菜单及添加/移除程序中不可见 可以使用ClickOnce进行部署 在浏览器中运行 类似页面浏览 在线工作 需要访问原部署的URL 总是最新的。 在安全沙箱中运行 没有安全与安装的提示 27 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
28
XAML Browser Applications 安全沙箱
4/24/2019 6:18 PM XAML Browser Applications 安全沙箱 代码访问安全性(CAS) 基于许可沙箱 应用会根据其部署源受于一定限制 基于浏览器应用运行在沙箱中 应用被赋于一定的权限集 超出许可的动作会引了安全异常 Full Trust (Standalone Apps) Secondary Windows, File System Access, WCF, Registry Access… Internet Zone (XBAP) Isolated Storage, Site of Origin Access, Printing, 3D, Flow, Animation… 28 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
29
XAML Browser Applications 深度防御功能
4/24/2019 6:18 PM XAML Browser Applications 深度防御功能 代码访问安全 – 第一道防线 安全透明/ 安全鉴定 在Vista中IE的权限是很低的。 在其它平台上,移除了IE6的管理员凭证 与浏览器进程隔离 边界高度隔离 可信赖计算的最佳实践 威胁建模、代码复查、静态分析等 29 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
30
WPF In Browser
31
回顾 WPF介绍 应用提供了应用生命周期管理的功能 用户体验模型至关重要。
4/24/2019 6:18 PM 回顾 WPF介绍 应用提供了应用生命周期管理的功能 用户体验模型至关重要。 可以使用内建的模型或定制新的模型 根据功能需求与用户体验来选择使用XBAP应用还是Windows应用 延续了浏览器的体验,而且不用安装。 Window应用可以得到更高的信认并可离线工作,但需要安装。 31 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
32
WPF/.NET Framework 3.0 Community Site
Windows Vista Developer Center WPF/.NET Framework 3.0 Community Site
33
填反馈表
Similar presentations