Presentation is loading. Please wait.

Presentation is loading. Please wait.

READING, WRITING, BINDING, VALIDATING AND VISUALISING YOUR DATA Business value with Silverlight.

Similar presentations


Presentation on theme: "READING, WRITING, BINDING, VALIDATING AND VISUALISING YOUR DATA Business value with Silverlight."— Presentation transcript:

1 READING, WRITING, BINDING, VALIDATING AND VISUALISING YOUR DATA Business value with Silverlight

2 Introductions Me  I work at Datacom, on a large range of projects, primarily user interfaces  I have been yearning to try Silverlight but haven’t had the chance at work  My blog is at www.robfe.com. It’s a bit... new?www.robfe.com You  Who’s done  Silverlight  Flash  Wpf  Astoria  ASP MVC  REST  LINQ to Entities  LINQ  C#

3 The Agenda Foundation  XAML  DependencyObjects and DependencyProperties  Templates, Styles & Resources  Layout Working with Data  Access (with Web Services & REST)  Binding  Validation  Visualisation

4 Business Value?

5 Foundations of Silverlight: XAML What is a Silverlight App?  A parallel universe of dlls  System.Windows.Controls classes arranged together (usually via XAML) XAML - a format for building objects via XML  WPF, Silverlight, WWF etc Why would you bother with XAML?  Designer support Web Page Silverlight host Application (App.xaml) UserControl (Page.xaml)

6 FoS: Dependency Properties Silverlight objects are DependencyObjects  DependencyObjects have DependencyProperties Child objects can “inherit” properties from their parents  Great for layout  Actually, you can set any DependencyProperty on any DependencyObject (but there might be no point)

7 FoS: Styles and Templates Styles can be used to “set” values on existing object trees  A bit like CSS  Bindings only work in WPF Templates can replace the object tree itself  ListView is the most common place to do this  We’ll go into this...

8 FoS: Layout and Animations Layout  It’s got some sweet layout controls  Grid, Canvas, StackPanel  No more cross browser issues Animations  It’s got some sweet animation support.  In XAML you declare the start and end values of properties  Colours, Positions, Opacities, Sizes  Easing  Makes things look “natural”  Subtle animations are good for business

9 Business Scenarios for Silverlight 90% of what we do has a central data store  Silverlight has to get its data over http (no database connection) Silverlight > ASPX etc  Stateful  Easy to bind  Validation can be very user friendly  You can make it look totally hot.  Rich visualisations User Armed with key data Leverages synergies Pays you money Silverlight client Data bindingValidationVisualisation Web Server Host Page Web Service for Data REST? Back end DatabaseBusiness LogicDomain model

10 Data Access Web Services REST  SQL Server Data Services AKA Astoria  See Diagram Sockets (push data) All data operations are asynchronous (BeginBlah, EndBlah) DEMO DatabaseLINQ to Entities modelDataServiceHttpDataServiceContext(Client)

11 Data Binding Databinding in Silverlight is very good  Hierarchy Navigation  DataContext inheritance  Two Way XAML: Code: txt1.SetBinding(TextBox.TextProperty, new Binding("Name"){Mode=BindingMode.TwoWay}); DEMO

12 Data Validation The BindingValidationError event bubbles up Bindings support single property validation:  ValidatesOnExceptions: Cause a validation error instead of throwing the exception  NotifyOnValidationError: Raise the BindingValidationError event if there is a binding error We can throw exceptions from within our property setters. DEMO

13 Data Visualisation Visual Properties can be databound  Canvas.Left, Grid.Row etc The visual elements in SL/WPF are really easy to work with  Great layout options  All visual elements are objects (no more DrawRectangle())  Templates also provide a lot of power DEMO

14 Tips, Tricks, Workarounds Astoria Client  Cast your IEnumerable queries into DataServiceQuery to get access to Expand and BeginExecute  When saving related records / foreign keys, you have to manually call AddLink on your context Astoria Service  Set config.UseVerboseErrors=true while debugging to get error messages out of your svc  Test it with Firebug/Fiddler/Charles  config.SetEntitySetAccessRule("*", EntitySetRights.All);

15 Tips, Tricks, Workarounds continued Expression Blend  Loads of draggy droppy support for templates, bindings, styles, gradients & paths. All the stuff you don’t want to hand code.  You can give a user control a “Design time size”  You have to reference a different DLL to get more controls  Don’t try and use DatePickerTextBox Silverlight  Sometimes your browser will cache your XAP – delete temp files if you don’t see your changes reflected  Really good JavaScript bridge  If you’re accessing services not on your domain, make sure you read up on cross domain JavaScript.

16 Thank you Questions? Feature Requests? Slides & Solution will be on my blog: www.robfe.comwww.robfe.com All comments, questions, donations totally appreciated: rob@robfe.comrob@robfe.com


Download ppt "READING, WRITING, BINDING, VALIDATING AND VISUALISING YOUR DATA Business value with Silverlight."

Similar presentations


Ads by Google