KEMBAR78
Architecting WPF Applications | PPTX
Architecting WPF ApplicationsPaul StovellSenior ConsultantWPF Technical SpecialistReadify
AgendaWPF OverviewInductive vs. Deductive UINavigationPresentation PatternsCompositionInter-view CommunicationDependency InjectionPartitioningLeveraging XAMLPerformance Considerations
WPF Overview
Unified Presentation
Web or Windows?WindowsIntranet                 InternetSilverlightWindows FormsJavaJava AppletsASP.NETWPF XBAPWPFAJAX
XBAP
XBAP
WPF Releases.NET Framework 3.0.NET Framework 3.5.NET Framework 3.5 Service Pack 1.NET Framework 4.0
Inductive vs. Deductive
Deductive UI
Deductive UI
Inductive UI
Inductive UI
Inductive vs. DeductiveWhy does it matter?UI composition PatternsNavigation PatternsService LayerChangeAddress vs. SaveCustomer
DataGrid
Navigation
Linked ListPage 1Page 2Page 4Page 3
Centralized DecisionsNavigation HandlerPage 1Page 2Page 3Page 4
Presentation Patterns
Presentation PatternsModel-View-ViewModelaka Presentation ModelModel-View-Presenteraka Supervising ControllerModel-View-Controller
Model View ViewModelChange Address ViewModelCustomerAddressAccountsChange Address ViewModel
Model View ViewModel (Wrapped)View ModelChange Address ViewCustomer VMAccount VMAddress VMChange Address ViewModelModelCustomerAccountAddress
Model View PresenterChange Address ViewModelCustomerIChangeAddressViewAddressAccountsChange Address Presenter
Model View Presenter with VMChange Address ViewModelCustomerChange Address ViewModelIChangeAddressViewAddressAccountsChange Address PresenterStateBehaviour
Model View ControllerControllerView 1Model 1View 2Nav RequestModel 2View 3Model 3
Presentation PatternsThings to consider:Does every view need separated presentation?Does every view need to follow the same pattern?Code Behind isn’t Evil (DataGrids are)MVPoo
UI Composition
Model-based CompositionRecent Orders ViewModelSearch ViewModelWeather ViewModelOrder ListSearchWeather
UI-based CompositionBottom-UpOrder ListTop Region2. PlaceNavigationBottom Region1. ResolveSearchWeather
UI-based CompositionTop-DownOrder ListTop RegionBottom RegionSearchWeather
Inter-View Communication
Inter-View CommunicationStandard .NET eventsSearch ModelChild model raises eventParent model forwards eventResults ModelCriteria Model
Inter-View CommunicationEvent AggregatorResults ModelCriteria ModelhubPublishHandlePublishHandleAdvert ModelRecent Searches Model
Event AggregatorAdvantages:Automatic thread switchingWeak eventsHook for cross-cutting concerns
Dependency Injection
Dependency Injection
Partitioning
PartitioningSplitting partitions:By SKUBy featureBy teamBy department
PartitioningManaging partitions:With solutionsWith projectsWith assemblies
PartitioningResolving:Hard-codedConfigDiscovery
PartitioningAlso consider:Deployment and patchingInter-partition dependenciesDev time vs. build time partitioning
PartitioningRemember: assemblies are like waternecessary for life……but too much can kill you!
Leveraging XAML
Abstractions<Grid>   <..>   <Label Grid.Row="0" Grid.Column="0"        Content="First Name:"        Target="{Binding ElementName=FirstNameTextBox}"       />   <TextBoxGrid.Row="0" Grid.Column="1"       Name="FirstNameTextBox"       Text="{Binding Path=FirstName}"       /></Grid><Form>    <Field For="{Binding Path=FirstName}" />    <Field For="{Binding Path=LastName}" />    <Field For="{Binding Path=EmailAddress}" /></Form>
Consistency<TextBlock   Foreground="Red"  Text="Please enter..."   /><TextBlock   Foreground="{StaticResourceColor.Bad}"  Text="Please enter..."    />
Style Catalogues<TextBox Width="300" .../><TextBox Width="156" .../><TextBox Width="215" .../><TextBox Style="{StaticResourceTextBox.Big}" /><TextBox Style="{StaticResourceTextBox.Small}" /><TextBox Style="{StaticResourceTextBox.Medium}" />
BehavioursConsider this:Developers don't write code; they build tools for designers
Performance Considerations
Performance ConsiderationsRetained scene vs. Immediate ModeVirtualization (data and UI)Memory leaksThird party componentsPerformance test from day 1
Q&ALinks:http://www.codeplex.com/CompositeWPFhttp://magellan.codeplex.comhttp://www.galasoft.ch/mvvm/getstarted/http://caliburn.codeplex.comPaul Stovellpaul@paulstovell.comwww.paulstovell.com

Architecting WPF Applications