Upload
norman-wilkins
View
217
Download
0
Tags:
Embed Size (px)
Citation preview
1
Windows Presentation Foundation Windows Presentation Foundation ("Avalon"): Using Application ("Avalon"): Using Application ServicesServices
Lauren LavoieLauren LavoiePRS314PRS314Program ManagerProgram ManagerMicrosoft CorporationMicrosoft [email protected]@microsoft.comhttp://laurenlavoie.com/avalonhttp://laurenlavoie.com/avalon
2
OutlineOutlineCreating a smart client applicationCreating a smart client application
Demo: ChefalonDemo: Chefalon
Smart client app challengesSmart client app challenges
Demo: Runtime management and Demo: Runtime management and resourcesresources
Demo: Storage and user experience Demo: Storage and user experience modelmodel
Creating a rich browser applicationCreating a rich browser applicationWeb application challengesWeb application challenges
Web Browser ApplicationsWeb Browser Applications
Demo: Moving Chefalon into the Demo: Moving Chefalon into the browserbrowser
Q&AQ&A
3
ChefalonChefalon
4
Application Model Application Model ChallengesChallenges
App frameworks are App frameworks are restrictiverestrictive
Infrastructure for Infrastructure for user experience user experience models doesn’t existmodels doesn’t exist
Platforms don’t Platforms don’t provide good provide good metaphors for app-metaphors for app-level managementlevel management
5
App State and Runtime App State and Runtime ManagementManagement
<Application><Application> is the base class for is the base class for an appan app
Starts and stops the applicationStarts and stops the application
ResourcesResourcesA place for your app-global stateA place for your app-global stateProperty bagProperty bag
SubclassingSubclassing
Events rather than WM_* messagesEvents rather than WM_* messagesActivation, deactivationActivation, deactivation
App exit, session endingApp exit, session ending
Window managementWindow management
6
Application ResourcesApplication ResourcesDeclarative model for loading Declarative model for loading resourcesresources
<Frame Source=“Salmon.xaml” /><Frame Source=“Salmon.xaml” />
<Frame Source=<Frame Source=““pack://siteoforigin:,,Quiche.xaml” />pack://siteoforigin:,,Quiche.xaml” />
<Frame Source=<Frame Source= “ “Food;Component/Egg.xaml” />Food;Component/Egg.xaml” />
<Frame Source=“Mushroom.xaml” /><Frame Source=“Mushroom.xaml” />
Resources in the Resources in the appapp
Loose files in app Loose files in app dirdir
From site of originFrom site of origin In another In another assemblyassembly
Navigate(new Uri(“Mushroom.xaml”, Navigate(new Uri(“Mushroom.xaml”, UriKind.RelativeOrAbsolute));UriKind.RelativeOrAbsolute));
Navigate(new Uri(“Salmon.xaml”, Navigate(new Uri(“Salmon.xaml”, UriKind.RelativeOrAbsolute));UriKind.RelativeOrAbsolute));
Navigate(newNavigate(newUri(Uri(“pack://siteoforigin:,,Quiche.xaml”“pack://siteoforigin:,,Quiche.xaml” , , UriKind.RelativeOrAbsolute));UriKind.RelativeOrAbsolute));
Navigate(new Navigate(new Uri(“Food;Component/Egg.xaml”, Uri(“Food;Component/Egg.xaml”, UriKind.RelativeOrAbsolute)); UriKind.RelativeOrAbsolute));
7
Chefalon: Basic Application Chefalon: Basic Application FrameworkFramework
8
Persistent Storage and Persistent Storage and SettingsSettings
ApplicationApplication
CookieCookiess
Isolated Isolated StoragStoragee
File File SystemSystem
Windows Windows RegistryRegistry
.confi.configg
9
User Experience ModelUser Experience ModelFlavors of Windows ApplicationsFlavors of Windows Applications
MDI SDI / Dialog
Navigation-based SDI
Structured Navigation
Navigation-based MDI
10
User Experience ModelUser Experience ModelDialog-Based SDIDialog-Based SDI
Use Windows, Use Windows, Dialogs, and Dialogs, and ControlsControls
May manage May manage multiple windows in multiple windows in the same appthe same app
Features often Features often surfaced to users surfaced to users through menusthrough menusGreat UX paradigm for simple or frequent Great UX paradigm for simple or frequent taskstasks
The user is in controlThe user is in control
// Window1.xaml// Window1.xaml
<Window x:Class=<Window x:Class=““AApppp.Window1.Window1” ...” ...>> <DockPanel> <DockPanel> <Menu><Menu> <!-- define menu here --><!-- define menu here --> </Menu></Menu>
<!-- controls and UI here --><!-- controls and UI here --> </DockPanel></DockPanel></Window></Window>
11
User Experience ModelUser Experience ModelBasic NavigationBasic Navigation
Great UX paradigm for tasks that are Great UX paradigm for tasks that are unfamiliar to users or involve several stepsunfamiliar to users or involve several steps
User may be led through steps or can User may be led through steps or can safely exploresafely explore
Use Pages, Use Pages, Hyperlinks, FramesHyperlinks, Frames
NavigationWindow NavigationWindow created implicitly created implicitly when StartupUri is when StartupUri is setset
Navigation UI and Navigation UI and history provided history provided out of the boxout of the box
// Page1.xaml// Page1.xaml
<<PagePage x:Class= x:Class=““AApppp..PagePage11” ...” ...>> <TextBlock> <TextBlock> <Hyperlink <Hyperlink NavigateUri=“page2.xaml”>Go To Page NavigateUri=“page2.xaml”>Go To Page 2</Hyperlink>2</Hyperlink> </TextBlock></TextBlock></Page></Page>
// Page2.xaml// Page2.xaml
<Page x:Class=“App.Page2” ...><Page x:Class=“App.Page2” ...> <TextBlock>This is Page 2<TextBlock>This is Page 2 </TextBlock></TextBlock></Page></Page>
12
Chefalon: Adding Chefalon: Adding Navigation FunctionalityNavigation Functionality
13
Problems with Simple Problems with Simple Navigation Navigation Problems with Simple Problems with Simple Navigation Navigation
Hyperlink == GOTO
http://www.site.com/login.aspx?param1=hello&back=homepage.aspx
14
Structured NavigationStructured NavigationSolving the Problems with Simple Solving the Problems with Simple NavigationNavigation
Structured NavigationStructured NavigationSolving the Problems with Simple Solving the Problems with Simple NavigationNavigation
PageFunctions == function PageFunctions == function callscalls
PageFunctions == function PageFunctions == function callscalls
15
User Experience ModelUser Experience ModelStructured NavigationStructured Navigation
Great UX paradigm for tasks involving Great UX paradigm for tasks involving a sophisticated flow of stepsa sophisticated flow of steps
The app drives the userThe app drives the user
Use PageFunctionUse PageFunction
PageFunction is PageFunction is called like a function, called like a function, returns result to returns result to callercaller
Upon finish, returns Upon finish, returns the user to the the user to the calling pagecalling page
May create May create sophisticated sophisticated topologiestopologies
// PF1.xaml// PF1.xaml
<<PageFunctionPageFunction x:Class= x:Class=““AApppp..PFPF11” ” x:TypeArguments=“Int32” ...x:TypeArguments=“Int32” ...>> <Grid><Grid> ...... </Grid></Grid></</PageFunctionPageFunction>>
// Page1.xaml.cs// Page1.xaml.cs
PF1 pf = new PageFunction1();PF1 pf = new PageFunction1();pf.InitializeComponent();pf.InitializeComponent();pf.Return += new pf.Return += new ReturnEventHandler<int>(pf_Return);ReturnEventHandler<int>(pf_Return);this.NavigationService.Navigate(pf);this.NavigationService.Navigate(pf);
16
Chefalon: Adding Chefalon: Adding Structured NavigationStructured Navigation
17
Web Application Web Application ChallengesChallenges
Vastly different Vastly different programming models programming models for Web and Windows for Web and Windows appsapps
Making highly Making highly interactive, interactive, personalized Web personalized Web apps is hardapps is hard
Creating interactive Creating interactive apps often requires a apps often requires a tradeoff with securitytradeoff with security
18
Web Browser Applications Web Browser Applications (WBA)(WBA)Moving WPF to the WebMoving WPF to the WebRun in a security sandboxRun in a security sandbox
Have no security or installation promptHave no security or installation prompt
Are not installedAre not installedNo Start Menu or Add/Remove Programs No Start Menu or Add/Remove Programs presencepresence
Use ClickOnce for deploymentUse ClickOnce for deployment
Run in the browserRun in the browserFamiliarity of web browsingFamiliarity of web browsing
Are “online only” appsAre “online only” apps
19
Web Browser ApplicationsWeb Browser ApplicationsThe Security SandboxThe Security Sandbox
Web Browser Apps run in a sandboxWeb Browser Apps run in a sandbox
Full Trust (Standalone Full Trust (Standalone Apps)Apps)
Secondary Windows, File Secondary Windows, File System Access, WCF, System Access, WCF,
Registry Access…Registry Access…
Internet Zone Internet Zone (WBA)(WBA)
Isolated Storage, Site of Isolated Storage, Site of Origin Access, Printing, Origin Access, Printing, 3D, Flow, Animation…3D, Flow, Animation…
Code Access Security (CAS)Code Access Security (CAS)Permission-based sandboxPermission-based sandbox
Applications are limited by deployment Applications are limited by deployment zonezone
App is granted App is granted specific set of specific set of permissionspermissions
Attempt to use Attempt to use features not enabled features not enabled in sandbox raises in sandbox raises SecurityExceptionSecurityException
20
Web Browser ApplicationsWeb Browser ApplicationsThe defense-in-depth foundationThe defense-in-depth foundation
Code Access Security – 1Code Access Security – 1stst line of defense line of defenseSecurity Transparent / Security CriticalSecurity Transparent / Security Critical
IE7 Protected Mode on Windows VistaIE7 Protected Mode on Windows VistaOn other platforms, remove IE6’s admin tokenOn other platforms, remove IE6’s admin token
Out of process from browserOut of process from browserHard isolation boundaryHard isolation boundary
Trustworthy Computing best practicesTrustworthy Computing best practicesThreat models, code reviews, static toolsThreat models, code reviews, static tools
21
Web Browser ApplicationsWeb Browser ApplicationsConverting a desktop app to a web Converting a desktop app to a web appappSpecify “Web Browser Application”Specify “Web Browser Application”
Using the Visual Studio 2005 templateUsing the Visual Studio 2005 template
By setting 3 properties in your project fileBy setting 3 properties in your project file
Remove non-sandbox friendly codeRemove non-sandbox friendly codeConditional blocksConditional blocks
Runtime checksRuntime checks// Get AppDomain’s permission set// Get AppDomain’s permission setPermissionSet aDPermSet = PermissionSet aDPermSet = AppDomain.CurrentDomain.DefaultGrantSeAppDomain.CurrentDomain.DefaultGrantSet.ApplicationTrust.PermissionSet;t.ApplicationTrust.PermissionSet;PermissionSet permSet = new PermissionSet permSet = new PermissionSet();PermissionSet();permSet.AddPermission(new permSet.AddPermission(new UIPermission(UIPermissionWindow.AllWinUIPermission(UIPermissionWindow.AllWindows);dows);
// Set cache bit // Set cache bit _bindToWindow = !_bindToWindow = !permSet.IsSubsetOf(aDPermSet);permSet.IsSubsetOf(aDPermSet);
#if (WBA)#if (WBA) // Write to iso storage// Write to iso storage#else#else // Write to file system// Write to file system#endif#endif
22
Chefalon: Moving into the Chefalon: Moving into the BrowserBrowser
23
Practical Web Browser Practical Web Browser ApplicationsApplicationsMigrating or integrating with your existing Migrating or integrating with your existing sitesiteMultiple renderings – WPF for the Multiple renderings – WPF for the
premium experiencepremium experienceSniffing the UserAgent stringSniffing the UserAgent string
Leveraging your existing contentLeveraging your existing contentHosting HTML in WPFHosting HTML in WPF
Hosting WPF in HTMLHosting WPF in HTML
Interop with an existing backendInterop with an existing backendUsing cookiesUsing cookies
Use XSLT to transform to loose XAMLUse XSLT to transform to loose XAML
24
Web Browser Apps and Installed Web Browser Apps and Installed AppsAppsTwo great flavors of WPF hostingTwo great flavors of WPF hosting
Web Browser AppsWeb Browser AppsSafe and easy for usersSafe and easy for users
Seamless browser experience – no Seamless browser experience – no prompts!prompts!
Power of the platform on the WebPower of the platform on the WebInstalled AppsInstalled Apps
Can use non-sandbox featuresCan use non-sandbox features
Can create immersive experiencesCan create immersive experiences
Can provide offline supportCan provide offline support
““Sticky” desktop presenceSticky” desktop presence
25
SummarySummary
WPF provides options for app WPF provides options for app managementmanagement
Low policy primitives for system and Low policy primitives for system and data managementdata management
Built-in infrastructure for common user Built-in infrastructure for common user experience modelsexperience models
Web Browser Applications give you Web Browser Applications give you the power of WPF on the Webthe power of WPF on the Web
Runs in a security sandboxRuns in a security sandbox
Seamless browser experienceSeamless browser experience
26
Community ResourcesCommunity ResourcesAt PDCAt PDC
For more information, go seeFor more information, go seePRS330: Creating Rich Content Experiences in Your PRS330: Creating Rich Content Experiences in Your ApplicationsApplications
FUN222: Installation Technologies for Windows VistaFUN222: Installation Technologies for Windows Vista
Labs: PRSHOL09, PRSHOL10Labs: PRSHOL09, PRSHOL10
Ask The ExpertsAsk The Experts
Track lounge: I’ll be there Thu 9:30-12:30Track lounge: I’ll be there Thu 9:30-12:30
After PDCAfter PDCIf you missed this related session, watch on the If you missed this related session, watch on the DVDDVD
PRS313: Integrating with Your Win32/MFC ApplicationPRS313: Integrating with Your Win32/MFC Application
http://laurenlavoie.com/avalonhttp://laurenlavoie.com/avalon
MSDN dev center: MSDN dev center: http://http://msdn.microsoft.com/smartclientmsdn.microsoft.com/smartclient//
Channel 9 tag: Channel 9 tag: http://channel9.msdn.com/tags/Avalonhttp://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.