1 / 27

Windows Presentation Foundation ("Avalon"): Using Application Services

Windows Presentation Foundation ("Avalon"): Using Application Services. Lauren Lavoie PRS314 Program Manager Microsoft Corporation llavoie@microsoft.com http://laurenlavoie.com/avalon. Outline. Creating a smart client application Demo: Chefalon Smart client app challenges

stevie
Download Presentation

Windows Presentation Foundation ("Avalon"): Using Application Services

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Windows Presentation Foundation ("Avalon"): Using Application Services Lauren Lavoie PRS314 Program Manager Microsoft Corporation llavoie@microsoft.com http://laurenlavoie.com/avalon

  2. Outline • Creating a smart client application • Demo: Chefalon • Smart client app challenges • Demo: Runtime management and resources • Demo: Storage and user experience model • Creating a rich browser application • Web application challenges • Web Browser Applications • Demo: Moving Chefalon into the browser • Q&A

  3. Chefalon

  4. Application Model Challenges • App frameworks are restrictive • Infrastructure for user experience models doesn’t exist • Platforms don’t provide good metaphors for app-level management

  5. App State and Runtime Management • <Application> is the base class for an app • Starts and stops the application • Resources • A place for your app-global state • Property bag • Subclassing • Events rather than WM_* messages • Activation, deactivation • App exit, session ending • Window management

  6. Application ResourcesDeclarative model for loading resources Loose files in app dir Resources in the app <Frame Source=“Mushroom.xaml” /> <Frame Source=“Salmon.xaml” /> Navigate(new Uri(“Mushroom.xaml”, UriKind.RelativeOrAbsolute)); Navigate(new Uri(“Salmon.xaml”, UriKind.RelativeOrAbsolute)); From site of origin In another assembly <Frame Source= “Food;Component/Egg.xaml” /> <Frame Source= “pack://siteoforigin:,,Quiche.xaml” /> Navigate(new Uri(“Food;Component/Egg.xaml”, UriKind.RelativeOrAbsolute)); Navigate(newUri(“pack://siteoforigin:,,Quiche.xaml”, UriKind.RelativeOrAbsolute));

  7. Chefalon: Basic Application Framework

  8. Persistent Storage and Settings Cookies Application File System Isolated Storage Windows Registry .config

  9. User Experience ModelFlavors of Windows Applications SDI / Dialog MDI Structured Navigation Navigation-based SDI Navigation-based MDI

  10. User Experience ModelDialog-Based SDI • Use Windows, Dialogs, and Controls • May manage multiple windows in the same app • Features often surfaced to users through menus // Window1.xaml <Window x:Class=“App.Window1” ...> <DockPanel> <Menu> <!-- define menu here --> </Menu> <!-- controls and UI here --> </DockPanel> </Window> Great UX paradigm for simple or frequent tasks The user is in control

  11. User Experience ModelBasic 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 </TextBlock> </Page> Use Pages, Hyperlinks, Frames NavigationWindow created implicitly when StartupUri is set Navigation UI and history provided out of the box Great UX paradigm for tasks that are unfamiliar to users or involve several steps User may be led through steps or can safely explore

  12. Chefalon: Adding Navigation Functionality

  13. Problems with Simple Navigation Hyperlink == GOTO http://www.site.com/login.aspx?param1=hello&back=homepage.aspx

  14. Structured NavigationSolving the Problems with Simple Navigation PageFunctions == function calls

  15. User Experience ModelStructured Navigation // PF1.xaml <PageFunction x:Class=“App.PF1” 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); • Use PageFunction • PageFunction is called like a function, returns result to caller • Upon finish, returns the user to the calling page • May create sophisticated topologies Great UX paradigm for tasks involving a sophisticated flow of steps The app drives the user

  16. Chefalon: Adding Structured Navigation

  17. Web Application Challenges • Vastly different programming models for Web and Windows apps • Making highly interactive, personalized Web apps is hard • Creating interactive apps often requires a tradeoff with security

  18. Web Browser Applications (WBA)Moving WPF to the Web • Run in a security sandbox • Have no security or installation prompt • Are not installed • No Start Menu or Add/Remove Programs presence • Use ClickOnce for deployment • Run in the browser • Familiarity of web browsing • Are “online only” apps

  19. Web Browser ApplicationsThe Security Sandbox • Web Browser Apps run in a sandbox • Code Access Security (CAS) • Permission-based sandbox • Applications are limited by deployment zone • App is granted specific set of permissions • Attempt to use features not enabled in sandbox raises SecurityException Full Trust (Standalone Apps) Secondary Windows, File System Access, WCF, Registry Access… Internet Zone (WBA) Isolated Storage, Site of Origin Access, Printing, 3D, Flow, Animation…

  20. Web Browser ApplicationsThe defense-in-depth foundation • Code Access Security – 1st line of defense • Security Transparent / Security Critical • IE7 Protected Mode on Windows Vista • On other platforms, remove IE6’s admin token • Out of process from browser • Hard isolation boundary • Trustworthy Computing best practices • Threat models, code reviews, static tools

  21. Web Browser ApplicationsConverting a desktop app to a web app • Specify “Web Browser Application” • Using the Visual Studio 2005 template • By setting 3 properties in your project file • Remove non-sandbox friendly code • Conditional blocks • Runtime checks • //  Get AppDomain’s permission set • PermissionSet aDPermSet = AppDomain.CurrentDomain.DefaultGrantSet.ApplicationTrust.PermissionSet; • PermissionSet permSet = new PermissionSet(); • permSet.AddPermission(new • UIPermission(UIPermissionWindow.AllWindows); • //  Set cache bit • _bindToWindow = !permSet.IsSubsetOf(aDPermSet); • #if (WBA) • // Write to iso storage • #else • // Write to file system • #endif

  22. Chefalon: Moving into the Browser

  23. Practical Web Browser ApplicationsMigrating or integrating with your existing site • Multiple renderings – WPF for the premium experience • Sniffing the UserAgent string • Leveraging your existing content • Hosting HTML in WPF • Hosting WPF in HTML • Interop with an existing backend • Using cookies • Use XSLT to transform to loose XAML

  24. Web Browser Apps and Installed AppsTwo great flavors of WPF hosting • Web Browser Apps • Safe and easy for users • Seamless browser experience – no prompts! • Power of the platform on the Web • Installed Apps • Can use non-sandbox features • Can create immersive experiences • Can provide offline support • “Sticky” desktop presence

  25. Summary • WPF provides options for app management • Low policy primitives for system and data management • Built-in infrastructure for common user experience models • Web Browser Applications give you the power of WPF on the Web • Runs in a security sandbox • Seamless browser experience

  26. Community Resources • At PDC • For more information, go see • PRS330: Creating Rich Content Experiences in Your Applications • FUN222: Installation Technologies for Windows Vista • Labs: PRSHOL09, PRSHOL10 • Ask The Experts • Track lounge: I’ll be there Thu 9:30-12:30 • After PDC • If you missed this related session, watch on the DVD • PRS313: Integrating with Your Win32/MFC Application • http://laurenlavoie.com/avalon • MSDN dev center: http://msdn.microsoft.com/smartclient/ • Channel 9 tag: http://channel9.msdn.com/tags/Avalon

  27. © 2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

More Related