data driven wpf and silverlight applications
Post on 18-Oct-2014
3.188 views
DESCRIPTION
TRANSCRIPT
![Page 1: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/1.jpg)
Data Driven WPF and Silverlight ApplicationsData Driven WPF and Silverlight Applications
Dave AllenISV Application ArchitectDeveloper and Platform GroupMicrosoft UK
![Page 2: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/2.jpg)
AgendaAgenda
Windows Presentation FoundationSilverlightEntity FrameworkWCF Data ServicesSilverlight & WCF Data ServicesSilverlight & WCF RIA Services
![Page 3: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/3.jpg)
The Windows Client PlatformThe Windows Client Platform
WPFSilverlight
Silverlight Mobile
.NET
XAMLDesktopWeb
Mobile
![Page 4: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/4.jpg)
Windows Presentation FoundationWindows Presentation Foundation
Now in it’s forth release: 3.0, 3.5, 3.5 SP1, 4.0Highly stable platform for rich client applicationsMany bug fixes and supplemental featuresPerformance optimizations – especially cold start-up
Some mixed messages on it’s initial releaseWinForms is dead, no further development – not true!Backtrack – WPF isn’t really suitable for LOB – was true!Tooling not good enough for RAD of LOB apps – was true!
WPF is moving into mainstream LOBWPF 4.0 primary goal is LOB applicationsWPF Toolkit still available for supplemental features
![Page 5: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/5.jpg)
Silverlight (subset of WPF)Silverlight (subset of WPF)
Now in it’s forth release: 1.0, 2.0, 3.0, 4.0Platform for Rich Internet Applications (RIAs)Was originally a browser plug-in – still it’s primary useCross-browser, cross-platforms, cross-deviceIncludes .NET Runtime for C# and VB.NET
Some key featuresFrom SL3 will now run out-of-browserPrimary development platform for Windows Phone 7Includes rich networking stackIntegrates with HTML DOMSupports Isolated StorageSupports Safe File Open Dialog
![Page 6: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/6.jpg)
The user experienceThe user experience
![Page 7: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/7.jpg)
Primary features of WPF/SilverlightPrimary features of WPF/Silverlight
Vector based graphics, resolution-independent DPI Composition engine – allows nesting of all controlsUnified programming model for 2D, 3D, and MediaDeclarative programming model with XAMLHigh degree of control over stylingPowerful text engine and rendering Support different types of layoutAdvanced animation techniquesBuilt-in support for data bindingInterop with COM components
![Page 8: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/8.jpg)
WPF/Silverlight programming modelWPF/Silverlight programming model
Declarative programming with XAMLUI and code easy to separate1:1 matching between XAML and codeEasily toolable
<Button Width="100"> OK <Button.Background> LightBlue </Button.Background></Button>
XAMLButton b1 = new Button();b1.Content = "OK";b1.Background = new SolidColorBrush(Colors.LightBlue);b1.Width = 100;
C#Dim b1 As New Buttonb1.Content = "OK"b1.Background = New _ SolidColorBrush(Colors.LightBlue)b1.Width = 100
VB.NET
![Page 9: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/9.jpg)
DemoDemoWPF applications
![Page 10: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/10.jpg)
WPF/Silverlight UI componentsWPF/Silverlight UI components
ControlsLayout (Canvas, Border, StackPanel, Grid)Button, Calendar, Checkbox, Datagrid, DateTimePicker, GridSplitter, HyperLink, Image, ListBox, MediaElement, MultiScaleImage, Popup, Radio, Slider, TextBox, TextBlock, Toggle, Tooltip, etc.User Control – aggregation of existing controls
StylingReuse of UI properties across multiple controls
TemplatingOverride the way a control displays itselfData templating for customization of how data is displayed
Data BindingAllows binding of DataContext to a DataSource
![Page 11: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/11.jpg)
DemoDemoXAML and Silverlight anatomy
![Page 12: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/12.jpg)
Silverlight behind the scenesSilverlight behind the scenes
Background processing on separate threadSystem.ComponentModel.BackgroundWorker
Web ServicesSOAP 1.1 BP + Duplex, JSON, REST, RSS
SocketsOnly ports 4502-4534 are supported
Isolated StoragePer user, per application or per site/domain1Mb quota is the default, can be changed
File Open DialogAllows user to choose file, access the file stream, upload
![Page 13: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/13.jpg)
DemoDemoBehind the scenes
![Page 14: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/14.jpg)
Silverlight 3/4 FeaturesSilverlight 3/4 Features
Silverlight 360+ new controls addedData FormsDeep LinkingMulti-page ApplicationElement to Element bindingOut of Browser
Silverlight 4Printing supportRich text support32 new languages + right to left supportElevated privileges and COM automation (OOB)Webcam/Mic support
![Page 15: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/15.jpg)
WPF and Silverlight applicationsWPF and Silverlight applications
The paradigm shiftWPF not a natural fit for a WinForms, VB6, MFC developer that has grown up on GDI/User32XAML mark-up language more familiar to Web developersVisual Studio 2010 and Expression Blend generate XAML
WPF/Silverlight/XBAP – too many options?Decision is much simpler than you thinkIf you develop and deploy WinForms applications today
WPF is the natural choice – full fidelity .NETIf you develop WinForms applications and deployment is a problem, then XBAP could be the answer
Restricted to browser sandbox – full fidelity .NETAlso consider Out of Browser Silverlight
If you target the browser today and are moving to RIASilverlight is the natural next step
![Page 16: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/16.jpg)
ADO.NET Entity FrameworkADO.NET Entity Framework
Another data access technology!?!Not designed to replace what has gone beforeAddresses the OOP versus Relational problem
OOP very well establishedRelational have been around even longerBridging the gap has mostly been a manual taskSome 3rd party solutions, core problem remains
Objects != Relational DataFundamental problem is that relational data and objects in a programming language are NOT the same!
They have different semantics, languages, etc.But both are still needed in most applications
![Page 17: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/17.jpg)
ADO.NET Entity FrameworkADO.NET Entity Framework
Entity Data ModelModels Entities and relationships between those EntitiesHow does it bridge the gap between OOP and Relational
Common type systemInheritanceComplex types
EDM is scoped to just modeling design of application data
Entity FrameworkProvides services for consuming an EDM
Object ServicesEntity Client (EntityConnection, EntityDataReader, etc.)Entity SQLLINQ To EntitiesProvider model for 3rd party databases
![Page 18: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/18.jpg)
Entity Data ModelEntity Data Model
Application modelMapped to a persistence store
Comprised of three layers:Conceptual (CSDL)Mapping (MSL)Storage (SSDL)
Database agnosticNot compiled
Embed as a resourceStore externally
Conceptual
Mapping
Storage
Entity Data Model
![Page 19: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/19.jpg)
DemoDemoEntity Data Model
![Page 20: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/20.jpg)
Entity FrameworkEntity Framework
EDM consumption options:Entity Client
Entity SQLObject Services
Entity SQLLINQ To Entities
![Page 21: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/21.jpg)
Entity Framework – Service StackEntity Framework – Service Stack
LINQ To Entities
Object Services
Entity SQL
Entity Client
ADO.NET Provider
![Page 22: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/22.jpg)
Entity ClientEntity Client
Familiar ADO.NET object model:EntityCommandEntityConnectionEntityDataReaderEntity ParameterEntityTransaction
Text-based resultsRead-onlyUses Entity SQL
![Page 23: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/23.jpg)
Entity SQLEntity SQL
• SQL-like query language• Targets conceptual model• Database agnostic
T-SQL
Entity SQL
![Page 24: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/24.jpg)
Object ServicesObject Services
Object materialized queriesObjectContextObjectQuery<T>
Built on top of Entity ClientTwo query options:
Entity SQLLINQ
Runtime services:Unit of workIdentity trackingEager/explicit loading
![Page 25: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/25.jpg)
Entity Framework featuresEntity Framework features
Many to many relationshipsJoin tables ignored by designer in EDMSide-effect, relationships cannot contain dataLINQ supports this via the aggregate functions
InheritanceAllows Entities to be specializedMaps to CLR inheritanceFully supported in queries3 types of inheritance
Table per typeTable per hierarchyTable per concrete type
![Page 26: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/26.jpg)
Entity Framework features (2)Entity Framework features (2)
Entity splittingSingle entity split across multiple tables, something you may do with very large tables
Stored proceduresMost asked question about EFFully supported for CUD, map CUD functions to SPsMainly supported for queries, but doesn’t support composable queries, dynamic SQL within SPs
No metadata available at design-timeWorking against principles of EFDon’t use EF if you do this
Consider using TVF instead of SPs
![Page 27: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/27.jpg)
Entity Framework 4.0 new featuresEntity Framework 4.0 new features
Model-first developmentAutomatic pluralizationForeign keys in modelsPOCO class supportLazy loadingT4 Code GenerationTemplate customizationIObjectSetVirtual SaveChangesObjectStateManager control
Self-tracking entitiesSQL generation improvementsMore LINQ operator supportLINQ extensibilityExecuteStoreQueryExecuteStoreCommandSPROC import improvementsModel defined functionsWPF designer integration
![Page 28: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/28.jpg)
DemoDemoEntity Framework
![Page 29: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/29.jpg)
Data Service over HTTPData Service over HTTP
HTML + JavaScript
Data (XML, etc)
DLL + XAML
Data (XML, etc) Data (XML, etc)
Mashup UI
Data Feeds
AJAX Applicatio
ns
Silverlight Applicatio
ns
Online Services
Mashups
![Page 30: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/30.jpg)
Data Services todayData Services today
Web Service (ASMX, WCF)
1) GetCustomer(int id)
2) GetCustomers()
3) GetCustomers(string orderBy)
4) GetCustomers(string orderBy, string sortDirection)
5) GetCustomers(string orderBy, string sortDirection, int offset, int count)
6) GetCustomers(string orderBy, string sortDirection, int offset, int count, string filter, string filterValue)
![Page 31: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/31.jpg)
WCF Data ServicesWCF Data Services
Data publishing service using a RESTful interfaceJust uses HTTP
Therefore is able to use existing authentication mechanisms, and other infrastructure components such as caching and proxies
Uniform URL SyntaxEvery piece of information is addressablePredictable and flexible URL syntax
Multiple representationsATOMJSONPOX
![Page 32: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/32.jpg)
WCF Data Services (2)WCF Data Services (2)
Exposes an object model (not a database) over the web
Entity Data Model – WCF DS designed to work with EDMLINQ To SQL model, read-onlyCustom IQueryable<T> provider
Operation semantics, mapping of HTTP verbs for CRUD operations
GET – retrieve resourcePOST – create a resourcePUT – update a resourceDELETE – delete a resource
![Page 33: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/33.jpg)
URL ConventionsURL Conventions
Addressing entities and sets
Presentation options
Entity-set /Product
Single Entity /Product(324)
Member access /Product(324)/Name
Link traversal /ProductSubcategory(2)/Product
Deep access /ProductSubcategory(2)/Product(789)/Name
Raw value access /Product(324)/Name/$value
Sorting /Product?$orderby=Name
Filtering /Product?$filter=Color%20eq%20'Black'
Paging /Product?4top=10$skip=30
Inline expansion /ProductSubcategory?$expand=Product
![Page 34: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/34.jpg)
FiltersFilters
Logical operatorsand, or , asc, desc, eq, ne, true, false, gt, ge, lt, le, not, null
Arithmetic operatorsadd, sub, div, mul, mod
String functionsendswith, indexof, replace, startswith, tolower, toupper, trim, substring, substringof, concat, length
Date functionsyear, month, day, hour, minute, second
Math functionsround, floor, ceiling
Type functionsIs, Cast
![Page 35: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/35.jpg)
DemoDemoWCF Data Services
![Page 36: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/36.jpg)
Securing and Customizing Data ServicesSecuring and Customizing Data Services
VisibilityControl visibility per containerRead, Query, and Write options
AuthenticationIntegrates with the hosting environmentASP.NET, WCF, or Custom authentication module
InterceptorsExecute before HTTP GET/PUT/POST/DELETEEnable validation, custom row-level securityMaintain the REST interface
Service operationsAllow you to inject methods into URI if you need to
![Page 37: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/37.jpg)
ClientsClients
Data Service
![Page 38: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/38.jpg)
Silverlight ClientSilverlight Client
DataServiceHTTP
DataModel
DataServiceContext
ObjectModel
ServerClient
![Page 39: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/39.jpg)
DemoDemoSilverlight WCF Data Services Client
![Page 40: Data Driven WPF and Silverlight Applications](https://reader033.vdocuments.us/reader033/viewer/2022051207/54430478b1af9f410a8b482b/html5/thumbnails/40.jpg)