Download PRS314 - WPF: Using WPF Application Services

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

URL redirection wikipedia , lookup

Transcript
Windows Presentation Foundation
("Avalon"): Using Application Services
Lauren Lavoie
PRS314
Program Manager
Microsoft Corporation
[email protected]
http://laurenlavoie.com/avalon
1
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
2
Chefalon
3
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
4
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
5
Application Resources
Declarative model for loading resources
Resources in the app
Loose files in app dir
<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
<Frame Source=
“pack://siteoforigin:,,Quiche.xaml”
/>
Navigate(new
Uri(“pack://siteoforigin:,,Quiche.xaml” ,
UriKind.RelativeOrAbsolute));
In another assembly
<Frame Source=
“Food;Component/Egg.xaml” />
Navigate(new
Uri(“Food;Component/Egg.xaml”,
UriKind.RelativeOrAbsolute));
6
Chefalon: Basic Application
Framework
7
Persistent Storage and Settings
Cookies
File System
Application
Isolated
Storage
Windows Registry
.config
8
User Experience Model
Flavors of Windows Applications
MDI
SDI / Dialog
Structured
Navigation
Navigationbased MDI
Navigationbased SDI
9
User Experience Model
Dialog-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
10
User Experience Model
Basic Navigation
// Page1.xaml
<Page x:Class=“App.Page1” ...>
Use Pages,
<TextBlock>
Hyperlinks, Frames
<Hyperlink
NavigateUri=“page2.xaml”>Go To Page
2</Hyperlink>
NavigationWindow
</TextBlock>
</Page>
created implicitly
when StartupUri is set // Page2.xaml
<Page x:Class=“App.Page2” ...>
Navigation UI and
<TextBlock>This is Page 2
</TextBlock>
history provided out of
</Page>
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
11
Chefalon: Adding Navigation
Functionality
12
Problems with Simple Navigation
Hyperlink == GOTO
http://www.site.com/login.aspx?param1=hello&b
ack=homepage.aspx
13
Structured Navigation
Solving the Problems with Simple Navigation
PageFunctions == function calls
14
User Experience Model
Structured Navigation
// PF1.xaml
Use PageFunction
<PageFunction x:Class=“App.PF1”
x:TypeArguments=“Int32” ...>
<Grid>
PageFunction is called
...
</Grid>
like a function, returns
</PageFunction>
result to caller
// Page1.xaml.cs
Upon finish, returns the
PF1 pf = new PageFunction1();
user to the calling page pf.InitializeComponent();
pf.Return += new
ReturnEventHandler<int>(pf_Return);
May create
this.NavigationService.Navigate(pf);
sophisticated topologies
Great UX paradigm for tasks involving a
sophisticated flow of steps
The app drives the user
15
Chefalon: Adding Structured
Navigation
16
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
17
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
18
Web Browser Applications
The Security Sandbox
Code Access Security (CAS)
Permission-based sandbox
Applications are limited by deployment zone
Web Browser Apps run in a sandbox
App is granted specific
set of permissions
Attempt to use features
not enabled in sandbox
raises
SecurityException
Internet Zone (WBA)
Isolated Storage, Site of Origin
Access, Printing, 3D, Flow,
Animation…
Full Trust (Standalone
Apps)
Secondary Windows, File System
Access, WCF, Registry Access…
19
Web Browser Applications
The 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
20
Web Browser Applications
Converting 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
#if (WBA)
// Write to iso storage
#else
// Write to file system
#endif
// Get AppDomain’s permission set
PermissionSet aDPermSet =
AppDomain.CurrentDomain.DefaultGrantS
et.ApplicationTrust.PermissionSet;
PermissionSet permSet = new
PermissionSet();
permSet.AddPermission(new
UIPermission(UIPermissionWindow.AllWi
ndows);
// Set cache bit
_bindToWindow =
!permSet.IsSubsetOf(aDPermSet);
21
Chefalon: Moving into the
Browser
22
Practical Web Browser Applications
Migrating 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
23
Web Browser Apps and Installed Apps
Two 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
24
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
25
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/
26
© 2005 Microsoft Corporation. All rights reserved.
This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
27