SlideShare uma empresa Scribd logo
1 de 131
• .NET Architect @Ordina (www.ordina.be)
• Microsoft Regional Director and Client Dev MVP
• Techorama conference owner
• Speaker
• Visug user group lead (www.visug.be)
• Author
• Pluralsight trainer
www.snowball.be
gill@snowball.be
@gillcleeren
• Lecturer at New Media and Communications Technologie
• Owner eGuidelines
• IE Dev MVP
• Techorama conference owner
• Visug user group lead (www.visug.be)
kevinderudder.wordpress.be
kevin@e-guidelines.be
@kevinderudder
• Comparison of 2 technologies
• XAML (Windows 8, Silverlight)
• HTML
• Give you an overview of what each technology can or cannot do!
• 60 minutes
• 10 topics
• 3 minutes per topic
• YOU DECIDE!
• Please decide quickly!
• Round 1: Layout
• Round 2: Managing styles
• Round 3: Drawing
• Round 4: Local data
• Round 5: Services
• Round 6: Data binding
• Round 7: Audio and video playback
• Round 8: Controls
• Round 9: Uh oh, some OO!
• Round 10: Unit testing
• Final scores!
• Responsive, resolution independent
• Easy table based layout
• Layout management system built-in
• Layout is done based on a number of built-in elements (“layout
management elements”)
• General, available in any XAML technology:
• Canvas
• StackPanel
• Grid
• Silverlight
• DockPanel
• WrapPanel
• Windows 8 & Windows Phone 8.1
• GridView
• ListView
• Semantic Zoom
• Positional layout
• Positioning of elements is done relative to owning canvas
• Very lightweight container
• “Drawing” panel, similar to a Form in WinForms
• Not the best choice for
flexible, responsive UIs
• Positioning done based on
attached properties
<Canvas Width="150" Height="100" Background="Gray">
<Rectangle Canvas.Top="10" Canvas.Left="10"
Width="130" Height="80" Fill="Blue" />
<Canvas Canvas.Left="20" Canvas.Top="20"
Width="110" Height="60" Background="Black">
<Ellipse Canvas.Top="10"
Canvas.Left="10"
Width="90"
Height="40"
Fill="Orange" />
</Canvas>
</Canvas>
• Automatic layouting of its child elements
• Stacks elements horizontally or vertically
• Very simple control
• OK for flexible Uis
• Not for an entire page though
<StackPanel Background="Gray"
Orientation="Horizontal"
>
<Rectangle Width="100" Height="100"
Fill="Blue" />
<Ellipse Width="100" Height="100"
Fill="Orange" />
</StackPanel>
• Powerful layout control
• Ready for responsive UIs
• Versatile for all resolutions
• Not “shared” as the same control for tabular data display
• Not visible
• No rows and columns
• Each cell can contain 1 element by default
• More possible due to nesting
• Nesting is often applied for a page
<Grid Background="Gray" Width="100" Height="100">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Rectangle Fill="Blue" Width="50" Height="50"
Grid.Column="0" Grid.Row="0" />
<Rectangle Fill="Red" Width="50" Height="50"
Grid.Column="1" Grid.Row="0" />
<Rectangle Fill="Green" Width="50" Height="50"
Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" />
</Grid>
• ListView
• GridView
• FlipView
• Semantic zoom
• Touch-optimized!
<header />
<main>
<aside></aside>
<section>
<article>
<header />
<footer />
</article>
</section>
</main>
<footer />
• Layout in HTML is done by a combination of HTML <tags> and CSS {styles}
• Don’t position your elements by using <br/> or <p/> tags
• HTML
• Each element (except <div>) has its own purpose
• If you use older browsers, use modernizr or
add the elements via JavaScript to the DOM
main {
display: block;
}
aside > nav {
display: -ms-flex;
-ms-flex-flow: row wrap;
flex-flow: row wrap;
}
• Layout in HTML is done by a combination of HTML <tags> and CSS {styles}
• Don’t position your elements by using <br/> or <p/> tags
• CSS
• Hardest part
• Add a reset CSS to your page
• reset.css or normalize.css
• Use a Grid System to make this easier for you
• 960grid
• Twitter bootstrap
• …
• {display:block;} to have a newline before and after the element
• {display:inline;} to put the element inside text or another element
• {display:inline-block;} to have an inline element with features of a
block element like width and height
• {display:table;} to create
table in CSS instead of HTML
<div style="display: table;">
<div style="display: table-row;">
<div style="display: table-cell;">
</div>
</div>
</div>
• {display:flex;}•
•
•
•
.flex {
width: 525px;
height: 300px;
border: 1px solid #000000;
display: flex;
flex-direction: row;
}
.flex > div {
flex: 1 1 auto;
}
.flex > div:nth-child(1) {
background: #000000;
}
.flex > div:nth-child(2) {
background: #f3f32f;
}
.flex > div:nth-child(3) {
background: #ff0000;
}
• Make it easier to work with styles
• Make it possible to make styles use variables
• No easy way to maintain large CSS Stylesheets
• SOLUTION: CSS Precompilers
• SASS
• LESS
• Stylus
• CSS Crush
• …
@techdays-color: rgb(255,188,0);
@techdays-darkerColor: (@vision-color + #111);
body{
background-color: @vision-color;
border: 1px solid @vision-darkerColor;
}
@width: 960px;
.middle{
width: @width * 2 / 3;
}
.left, .right{
width: @width / 6;
}
header{
background-color: orange;
nav{
background-color: darken(orange, 10%);
}
nav a{ text-decoration: none;
&:hover{text-decoration: underline;}
}
}
header {background-color: orange;}
header nav {background-color: #cc8400;}
header nav a {text-decoration: none;}
header nav a:hover {text-decoration: underline;}
• Blocks of UI elements that can be reused
• Limited to properties of elements
• Are tied to type for which they are defined
<Grid>
<Grid.Resources>
<Style TargetType="Rectangle" x:Key="Outlined">
<Setter Property="StrokeThickness" Value="2" />
<Setter Property="Stroke" Value="Black"/>
</Style>
</Grid.Resources>
<Rectangle Fill="#FF808080" Width="100" Height="50"
Style="{StaticResource Outlined}"
StrokeThickness="5"
/>
</Grid>
• Should have name and TargetType defined
• TargetType is polymorphic
• Static or dynamic (only in WPF)
• Aren’t really cascading,
although we can build a
hierarchy of styles
• Similar to CSS
<Style x:Key="BaseControl"
TargetType="Control">
<Setter Property="FontWeight"
Value="Bold" />
</Style>
<Style x:Key="ButtonStyle1"
TargetType="Button"
BasedOn="{StaticResource BaseControl}">
<Setter Property="FontFamily"
Value="Verdana" />
<Setter Property="FontSize"
Value="18" />
</Style>
• Inside a style setter, we can do data-binding
• Not really a variable though
• How it works:
• Create an object
• Bind a style to it
• When the object changes, the bound values in the setters will also change
Object
Style
View
View
View
• Vector-based
• Resolution-independent
• All drawing is vector-based
• No problems with different resolution
• Based on hierarchy of shapes
• Shape base class
• Rectangle
• Ellipse
• Line
• Polygon
• Polyline
• Path
• Basic properties
• Fill
• Stroke
• Width
• Height
• Opacity
• Visibility
• Cursor (depending on platform)
• Shapes can have fill and stroke
• Brushes
• SolidColorBrush
• LinearGradientBrush
• RadialGradientBrush
• ImageBrush
• VideoBrush (depending on platform)
Fill
Stroke
<Path Stroke="Black" StrokeThickness="2">
<Path.Data>
<PathGeometry>
<PathGeometry.Figures>
<PathFigure StartPoint="5,25">
<PathFigure.Segments>
<BezierSegment Point1="25,0"
Point2="75,50"
Point3="95,25" />
</PathFigure.Segments>
</PathFigure>
</PathGeometry.Figures>
</PathGeometry>
</Path.Data>
</Path>
• Is not so easy, but great things can be achieved
• Posibilities
• Canvas
• SVG
• WebGL
• Plain Old JavaScript
• Which option you pick, JavaScript needs to be your friend
• Or you should try CSS3D
• Typical choice for most HTML games
• Simple
• But fast
• Bitmapped area, so drawn objects become part of the canvas which
makes it impossible to attach event handlers
• When objects move, you must redraw the canvas
• XML based vector graphics format
• Less performant but very flexible
• Each drawn object becomes part of the DOM
• Attach one or more event handlers to it
<svg width="320" height="320">
<defs>
<radialGradient id="circleGrad">
<stop offset="100%" stop-color="rgb( 0, 255, 0)" />
</radialGradient>
</defs>
<ellipse fill="url(#circleGrad)" stroke="#000" cx="50%“ cy="50%" rx="50%" ry="50%">
</ellipse>
</svg>
• Offer simple way to store user data locally
• If you want to store data locally, you can choose between these
options
• Cookies (which I will not explain)
• LocalStorage / SessionStorage
• IndexedDB
• WebSQL
• SessionStorage
• Temporary key/value pairs
• 1 session per tab/windows
• LocalStorage
• Same as session storage but persistant
• Global usage in multiple instances of your browser
localStorage.setItem("rememberMeForALongTime", anyObject);
sessionStorage.setItem("rememberMeForALittleWhile", anyObject);
var anyObject = sessionStorage.getItem("rememberMeForALittleWhile");
var anyObject = localStorage.getItem("rememberMeForALongTime");
• API for client-side storage of data
• Local and session storage is good for small amounts of data
• IndexedDB is ideal for large amounts of data
• Transactional database System
• Boost performance by using indexes
• Silverlight and Windows Phone define IsolatedStorage
• Can store data on Client Machine
• Size of storage is quota'd
• Mostly used to save state/settings
// Get the Store and Stream
using (IsolatedStorageFile file =
IsolatedStorageFile.GetUserStoreForApplication())
using (IsolatedStorageFileStream stream = file.CreateFile("Foo.config"))
{
// Save Some Data
StreamWriter writer = new StreamWriter(stream);
writer.WriteLine("AutoRun=true");
writer.Flush();
stream.Close();
}
// Get the Store and Stream
using (IsolatedStorageFile file =
IsolatedStorageFile.GetUserStoreForApplication())
using (IsolatedStorageFileStream stream =
file.OpenFile("Foo.config", FileMode.Open))
{
// Read Some Data
StreamReader rdr = new StreamReader(stream);
string config = rdr.ReadToEnd();
stream.Close();
}
• Simple usage to create Application Settings
• Use IsolatedStorageSettings to set/get settings
• ApplicationSettings are per .xap
• SiteSettings are per domain
IsolatedStorageSettings.ApplicationSettings["foo"] = "bar";
string appFoo = IsolatedStorageSettings.ApplicationSettings["foo"] as string;
IsolatedStorageSettings.SiteSettings["foo"] = "bar";
string siteFoo = IsolatedStorageSettings.SiteSettings["foo"] as string;
• Defines Application Data API
• Local
• Roaming
• Temporary
• Based on
• File system
• Settings (automatically persisted)
Local
Local folder
Roaming
Synced folder
Temp
Temp (local)
folder
Local
Settings
(Registry)
Synced
Settings
• Access (relational) data behind a service
• RESTful interaction with the service
• Silverlight, Windows 8 and Windows Phone share server-technologies that
they can communicate with
• ASMX
• WCF
• REST
• RSS
• Sockets
• oData
• …
• Common requirement is asynchronous communication
• Silverlight: callbacks
• Windows 8 and Windows Phone 8: await/async pattern
• Note: WPF can use the full, raw power of .NET and thus has even less restrictions
• Defines HttpClient (Silverlight and WP7 used WebClient)
• Works async
• HttpClient defines
• Get(Async)
• Returns an HttpResponseMessage
• Put(Async)
• Post(Async)
• Delete(Async)
RESTful!
• Windows 8.1 introduced a new version of the HttpClient
• Very similar API
• XML
• Linq-To-XML
• XmlReader/XmlWriter
• XmlSerializer
• JSON:
• Use the JsonObject and feed it the returned string
• DataContractJsonSerializer is also available
• JSON.NET
• Open source via NuGet
• Often the preferred choice
• If you want to retrieve data in a browser you have following options
• XMLHttpRequest
• WebSockets
• XMLHttpRequest defines an API for transferring data between a client
and a server
• Client initiates the request
• Synchronous or Asynchronous
• Based on the HTTP protocol
var xhr = new XMLHttpRequest();
xhr.open("GET", "URL", /*async*/ true);
xhr.onreadystatechange = function () {
if (xhr.readyState == COMPLETE) {
if (xhr.status == 200) {
var data = xhr.responseText;
}
}
}
xhr.send();
• API for socket connections between a browser and a server
• 2-way persistant connection between client and server
• Event-driven responses
• Send messages to the server and receive a response without polling the
server
var socket = new WebSocket("ws://www.mi6.com/socketserver", "yourprotocol");
function sendJamesBondOnASecretMission() {
var msg = {
type: "message",
mission: document.getElementById("mission").value,
id: clientID,
date: Date.now()
};
socket.send(JSON.stringify(msg));
}
socket.onmessage = function (event) {
var data = event.data;
}
• Don’t require us to write code like
TextBox1.Text = Person1.FirstName;
• Support two-way binding mode
• HTML does not know the concept of data binding
• You have data and you bind it to a control
• Plenty of JavaScript frameworks available to allow datavbinding in HTML
• Knockout
• Angular
• Mustache
• …
• Depending on the framework, the syntax may be different
<ul data-bind="foreach: secretAgents">
<li class="secretAgent">
<header>
<span data-bind="text: Name"></span>
</header>
<img data-bind="attr: {alt: name, id: id, src:img}" />
</li>
</ul>
viewModel = {
memories: ko.observableArray(items),
};
ko.applyBindings(viewModel);
<script id="secretAgents" type="text/html">
<ul>
{{#secretAgent}}
<li>{{name}}</li>
{{/secretAgent}}
</ul>
</script>
$(function () {
$.getJSON('@Url.Action("SecretAgents", "MI6")',
function (data) {
var html = Mustache.to_html($("#secretAgents").html(),{quotes: data });
$("#secretAgents").empty().append(html);
})
});
• Infrastructure for binding control properties to objects and collections
• Loosely-coupled model, already exists in ASP.NET, WinForms
• Simple and powerful model
• Source
• Any Object
• PropertyPath
• Path To Any Public Property
• Dynamic
• Supports multiple Binding Models
• OneTime, OneWay and TwoWay
Data
Object
Data bindingUI
Control
Converter
• Binding Syntax
• Markup Extension
• PropertyPath at a minimum
• Or specify Source
• Most often: use a DataContext on a base control
<TextBox Text="{Binding Name}" />
<Grid.Resources>
<local:Person x:Key="person1" />
</Grid.Resources>
...
<TextBox Text="{Binding Name, Source={StaticResource person1}}" />
<Grid DataContext={StaticResource person1}>
<TextBox Text="{Binding Name}" />
</Grid>
• Three Modes for Binding
• TwoWay, OneWay or OneTime
• Binding Syntax for Mode
• Binding Syntax
• OneWay and OneTime work with any object
• Property Based Reads
• TwoWay works with any objects
• Property Based Writes
<TextBlock Content="{Binding Name, Mode=TwoWay}" />
• Binding Interfaces
• Properties use INotifyPropertyChanged interface
• Collections use INotifyCollectionChanged interface
• Use ObservableCollection<> for Bindable Collections
• Easy way of media playback
• Support for common formats
• DRM
• MediaElement Loads or Streams content
• Loading:
• Plays Media as Progressively Downloaded
• Streamed:
• Downloads Chunk and plays it
• Support for
• Audio
• MP3
• Wav
• Video
• MP4
• WMV
• OGG video
• Support for
• Scrubbing
• Markers (subtitles)
<MediaElement
x:Name="MainMediaElement"
Height="300"
Width="640"
AreTransportControlsEnabled="True"
/>
• Silverlight, Windows Phone and Windows 8 support DRM
• Player Framework
• PlayReady Client
• Smooth Streaming SDK
• Audio and Video are already available for years
• But it was kind of difficult
• Now, it is much more simple to add media
• But sometimes, codecs can be a pain
function playPauseVideo() {
if (video.paused || video.ended) {
if (video.ended) {
video.currentTime = 0;
}
video.play();
}
else {
video.pause();
}
}
• Rich, native control set
• Basic
• Advanced
• Extensible control set
• Data visualizations
• HTML does not have a rich set of built-in controls
• And part of these controls are not supported by all browsers
• Built-in in HTML:
• TextBox
• PasswordBox
• Slider
• Progress
• Calendar
• DatePicker
• …
• Because of the open web community you can download code to
create extra controls
• Because of the open web community you can download code to
create extra controls
• Or you can download or buy extra controls
• jQuery UI
• Kendo UI
• Very rich control set
• Depending on technology
• Built-in in most XAML technologies
• TextBox
• PasswordBox
• Slider
• ProgressBar
• Calendar
• DatePicker
• …
• Content controls can contain other content
• One child
• Nested
• Controls
• Button
• CheckBox
• RadioButton
• TabControl
• ScrollViewer
• …
<Button>
<Button.Content>
<StackPanel>
<Image Source="pain.jpg" Width="100" />
<TextBlock TextAlignment="Center"
Text="Click Me" />
</StackPanel>
</Button.Content>
</Button>
• Bindable to IList or IEnumerable lists
• ItemsControl
• ListBox
• ComboBox (not in W8 and WP8)
• TabControl (not in W8 and WP8)
• DataGrid (not in W8 and WP8)
• Inherit from ItemsControl
• Similar to a repeater
<ItemsControl>
<Button Content="Click One" />
<Button Content="Click Two" />
</ItemsControl>
• Endless options when you start to template controls
• Allows re-definition of build-in controls
• Can redefine the XAML that is used to build control
• Look can be changed dramatically by changing XAML
• Feel can be changed
• Can only add built-in behavior
• E.g. no new methods, properties or events
• Support
• Classes
• Interfaces
• Inheritance
• Polymorphism
• It’s C# 
• XAML does know about OO principles going on behind the scenes
• DataTemplateSelectors
• Implicit Data Templates
• Data binding properties
• Although lots of people thing that you cannot do OO stuff in
JavaScript, you can
• It is not always pretty, but it is possible
JamesBond = (function() {
function JamesBond(name, drink) {
this.name = name;
this.drink = drink;
}
return JamesBond;
})();
sean = new JamesBond("Sean Connery", "Martini");
• Although lots of people thing that you cannot do OO stuff in
JavaScript, you can
• It is not always pretty, but it is possible
JamesBond = (function() {
function JamesBond(name, drink) {
this.name = name;
this.drink = drink;
}
return JamesBond;
})();
sean = new JamesBond("Sean Connery", "Martini");
• Today: make your live easier with compilers/transpilers/…
• CoffeeScript
• TypeScript
• …
# CoffeeScript
class JamesBond
constructor: (name, drink) ->
@name = name
@drink = drink
// TypeScript
class JamesBond{
name: string;drink: string;
constructor(name: string, drink: string) {
this.name = name;
this.drink = drink;
}
}
• ECMAScript 6 will add more OO functionality
• Future version of JavaScript
• Support an easy way for unit testing
• Unit testing frameworks
• Bunch of Testing Frameworks available
• QUnit
• Mocha
• TestSwarm
• Jasmine
• Tutti
• …
• Ideal with a JavaScript build system like grunt or gulp
• Silverlight includes support for unit testing directly from Visual Studio
• Run in the browser
• Not easy to integrate with build process
• In general, not a great story!
• Windows 8 support Unit Test Library template in
Visual Studio
• Based on Visual Studio Testing Framework
• Integrates with build process
• Other unit testing frameworks are supports
Comparing XAML and HTML: FIGHT!
Comparing XAML and HTML: FIGHT!
Comparing XAML and HTML: FIGHT!

Mais conteúdo relacionado

Mais procurados

New Elements & Features in CSS3
New Elements & Features in CSS3New Elements & Features in CSS3
New Elements & Features in CSS3
Jamshid Hashimi
 
W3Conf slides - The top web features from caniuse.com you can use today
W3Conf slides - The top web features from caniuse.com you can use todayW3Conf slides - The top web features from caniuse.com you can use today
W3Conf slides - The top web features from caniuse.com you can use today
adeveria
 
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
Deepak Sharma
 

Mais procurados (20)

CSS Walktrough Internship Course
CSS Walktrough Internship CourseCSS Walktrough Internship Course
CSS Walktrough Internship Course
 
Css 3
Css 3Css 3
Css 3
 
Css 3
Css 3Css 3
Css 3
 
Introduction to CSS3
Introduction to CSS3Introduction to CSS3
Introduction to CSS3
 
Svg
SvgSvg
Svg
 
Fundamental CSS3
Fundamental CSS3Fundamental CSS3
Fundamental CSS3
 
New Elements & Features in CSS3
New Elements & Features in CSS3New Elements & Features in CSS3
New Elements & Features in CSS3
 
Colors In CSS3
Colors In CSS3Colors In CSS3
Colors In CSS3
 
Intro to HTML 5 / CSS 3
Intro to HTML 5 / CSS 3Intro to HTML 5 / CSS 3
Intro to HTML 5 / CSS 3
 
W3Conf slides - The top web features from caniuse.com you can use today
W3Conf slides - The top web features from caniuse.com you can use todayW3Conf slides - The top web features from caniuse.com you can use today
W3Conf slides - The top web features from caniuse.com you can use today
 
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
 
Css3
Css3Css3
Css3
 
About Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JSAbout Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JS
 
Scaling the Web: Databases & NoSQL
Scaling the Web: Databases & NoSQLScaling the Web: Databases & NoSQL
Scaling the Web: Databases & NoSQL
 
From Shabby to Chic
From Shabby to ChicFrom Shabby to Chic
From Shabby to Chic
 
CSS3 - is everything we used to do wrong?
CSS3 - is everything we used to do wrong? CSS3 - is everything we used to do wrong?
CSS3 - is everything we used to do wrong?
 
Modular HTML, CSS, & JS Workshop
Modular HTML, CSS, & JS WorkshopModular HTML, CSS, & JS Workshop
Modular HTML, CSS, & JS Workshop
 
CSS - OOCSS, SMACSS and more
CSS - OOCSS, SMACSS and moreCSS - OOCSS, SMACSS and more
CSS - OOCSS, SMACSS and more
 
Getting Started With CSS
Getting Started With CSSGetting Started With CSS
Getting Started With CSS
 
Css3 Presetation
Css3 PresetationCss3 Presetation
Css3 Presetation
 

Semelhante a Comparing XAML and HTML: FIGHT!

LeSS in action
LeSS in actionLeSS in action
LeSS in action
Pu Shiming
 
Top 10 HTML5 features every developer should know!
Top 10 HTML5 features every developer should know!Top 10 HTML5 features every developer should know!
Top 10 HTML5 features every developer should know!
Gill Cleeren
 

Semelhante a Comparing XAML and HTML: FIGHT! (20)

Html5 more than just html5 v final
Html5  more than just html5 v finalHtml5  more than just html5 v final
Html5 more than just html5 v final
 
LeSS in action
LeSS in actionLeSS in action
LeSS in action
 
Trendsetting: Web Design and Beyond
Trendsetting: Web Design and BeyondTrendsetting: Web Design and Beyond
Trendsetting: Web Design and Beyond
 
CSS and CSS3
CSS and CSS3CSS and CSS3
CSS and CSS3
 
Top 10 HTML5 features every developer should know!
Top 10 HTML5 features every developer should know!Top 10 HTML5 features every developer should know!
Top 10 HTML5 features every developer should know!
 
Intro to CSS3
Intro to CSS3Intro to CSS3
Intro to CSS3
 
Css best practices style guide and tips
Css best practices style guide and tipsCss best practices style guide and tips
Css best practices style guide and tips
 
Training Html5 -CSS3 New things
Training Html5 -CSS3 New thingsTraining Html5 -CSS3 New things
Training Html5 -CSS3 New things
 
Bootstrap: the full overview
Bootstrap: the full overviewBootstrap: the full overview
Bootstrap: the full overview
 
Designing Your Next Generation Web Pages with CSS3
Designing Your Next Generation Web Pages with CSS3Designing Your Next Generation Web Pages with CSS3
Designing Your Next Generation Web Pages with CSS3
 
Course Tech 2013, Sasha Vodnik, A Crash Course in HTML5
Course Tech 2013, Sasha Vodnik, A Crash Course in HTML5Course Tech 2013, Sasha Vodnik, A Crash Course in HTML5
Course Tech 2013, Sasha Vodnik, A Crash Course in HTML5
 
Advanced sass/compass
Advanced sass/compassAdvanced sass/compass
Advanced sass/compass
 
WCBuf: CSS Display Properties versus HTML Semantics
WCBuf: CSS Display Properties versus HTML SemanticsWCBuf: CSS Display Properties versus HTML Semantics
WCBuf: CSS Display Properties versus HTML Semantics
 
Ease into HTML5 and CSS3
Ease into HTML5 and CSS3Ease into HTML5 and CSS3
Ease into HTML5 and CSS3
 
Rich and Beautiful: Making Attractive Apps in HTML5 [Wpg 2013]
Rich and Beautiful: Making Attractive Apps in HTML5 [Wpg 2013]Rich and Beautiful: Making Attractive Apps in HTML5 [Wpg 2013]
Rich and Beautiful: Making Attractive Apps in HTML5 [Wpg 2013]
 
The web standards gentleman: a matter of (evolving) standards)
The web standards gentleman: a matter of (evolving) standards)The web standards gentleman: a matter of (evolving) standards)
The web standards gentleman: a matter of (evolving) standards)
 
CSS3: Ripe and Ready to Respond
CSS3: Ripe and Ready to RespondCSS3: Ripe and Ready to Respond
CSS3: Ripe and Ready to Respond
 
SilverlightDevIntro
SilverlightDevIntroSilverlightDevIntro
SilverlightDevIntro
 
Unit-3-CSS-BWT.pptx
Unit-3-CSS-BWT.pptxUnit-3-CSS-BWT.pptx
Unit-3-CSS-BWT.pptx
 
Simply Responsive CSS3
Simply Responsive CSS3Simply Responsive CSS3
Simply Responsive CSS3
 

Mais de Gill Cleeren

Advanced MVVM in Windows 8
Advanced MVVM in Windows 8Advanced MVVM in Windows 8
Advanced MVVM in Windows 8
Gill Cleeren
 

Mais de Gill Cleeren (10)

Continuous integration and delivery with Xamarin and VSTS
Continuous integration and delivery with Xamarin and VSTSContinuous integration and delivery with Xamarin and VSTS
Continuous integration and delivery with Xamarin and VSTS
 
Real world apps with Xamarin and MVVM
Real world apps with Xamarin and MVVMReal world apps with Xamarin and MVVM
Real world apps with Xamarin and MVVM
 
Hello windows 10
Hello windows 10Hello windows 10
Hello windows 10
 
Building your first iOS app using Xamarin
Building your first iOS app using XamarinBuilding your first iOS app using Xamarin
Building your first iOS app using Xamarin
 
Building your first android app using Xamarin
Building your first android app using XamarinBuilding your first android app using Xamarin
Building your first android app using Xamarin
 
Building a community - BuildStuff Lithuania 2014
Building a community - BuildStuff Lithuania 2014Building a community - BuildStuff Lithuania 2014
Building a community - BuildStuff Lithuania 2014
 
C# everywhere: Xamarin and cross platform development
C# everywhere: Xamarin and cross platform developmentC# everywhere: Xamarin and cross platform development
C# everywhere: Xamarin and cross platform development
 
Getting started with jQuery
Getting started with jQueryGetting started with jQuery
Getting started with jQuery
 
Why you shouldn't dismiss windows 8 for your lob apps
Why you shouldn't dismiss windows 8 for your lob appsWhy you shouldn't dismiss windows 8 for your lob apps
Why you shouldn't dismiss windows 8 for your lob apps
 
Advanced MVVM in Windows 8
Advanced MVVM in Windows 8Advanced MVVM in Windows 8
Advanced MVVM in Windows 8
 

Último

Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 

Último (20)

%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 

Comparing XAML and HTML: FIGHT!

  • 1.
  • 2. • .NET Architect @Ordina (www.ordina.be) • Microsoft Regional Director and Client Dev MVP • Techorama conference owner • Speaker • Visug user group lead (www.visug.be) • Author • Pluralsight trainer www.snowball.be gill@snowball.be @gillcleeren
  • 3. • Lecturer at New Media and Communications Technologie • Owner eGuidelines • IE Dev MVP • Techorama conference owner • Visug user group lead (www.visug.be) kevinderudder.wordpress.be kevin@e-guidelines.be @kevinderudder
  • 4. • Comparison of 2 technologies • XAML (Windows 8, Silverlight) • HTML • Give you an overview of what each technology can or cannot do! • 60 minutes • 10 topics • 3 minutes per topic • YOU DECIDE! • Please decide quickly!
  • 5.
  • 6. • Round 1: Layout • Round 2: Managing styles • Round 3: Drawing • Round 4: Local data • Round 5: Services • Round 6: Data binding • Round 7: Audio and video playback • Round 8: Controls • Round 9: Uh oh, some OO! • Round 10: Unit testing • Final scores!
  • 7.
  • 8. • Responsive, resolution independent • Easy table based layout • Layout management system built-in
  • 9.
  • 10. • Layout is done based on a number of built-in elements (“layout management elements”) • General, available in any XAML technology: • Canvas • StackPanel • Grid • Silverlight • DockPanel • WrapPanel • Windows 8 & Windows Phone 8.1 • GridView • ListView • Semantic Zoom
  • 11. • Positional layout • Positioning of elements is done relative to owning canvas • Very lightweight container • “Drawing” panel, similar to a Form in WinForms • Not the best choice for flexible, responsive UIs • Positioning done based on attached properties <Canvas Width="150" Height="100" Background="Gray"> <Rectangle Canvas.Top="10" Canvas.Left="10" Width="130" Height="80" Fill="Blue" /> <Canvas Canvas.Left="20" Canvas.Top="20" Width="110" Height="60" Background="Black"> <Ellipse Canvas.Top="10" Canvas.Left="10" Width="90" Height="40" Fill="Orange" /> </Canvas> </Canvas>
  • 12. • Automatic layouting of its child elements • Stacks elements horizontally or vertically • Very simple control • OK for flexible Uis • Not for an entire page though <StackPanel Background="Gray" Orientation="Horizontal" > <Rectangle Width="100" Height="100" Fill="Blue" /> <Ellipse Width="100" Height="100" Fill="Orange" /> </StackPanel>
  • 13. • Powerful layout control • Ready for responsive UIs • Versatile for all resolutions • Not “shared” as the same control for tabular data display • Not visible • No rows and columns • Each cell can contain 1 element by default • More possible due to nesting • Nesting is often applied for a page
  • 14. <Grid Background="Gray" Width="100" Height="100"> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="2*"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> <Rectangle Fill="Blue" Width="50" Height="50" Grid.Column="0" Grid.Row="0" /> <Rectangle Fill="Red" Width="50" Height="50" Grid.Column="1" Grid.Row="0" /> <Rectangle Fill="Green" Width="50" Height="50" Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" /> </Grid>
  • 15. • ListView • GridView • FlipView • Semantic zoom • Touch-optimized!
  • 16.
  • 17. <header /> <main> <aside></aside> <section> <article> <header /> <footer /> </article> </section> </main> <footer /> • Layout in HTML is done by a combination of HTML <tags> and CSS {styles} • Don’t position your elements by using <br/> or <p/> tags • HTML • Each element (except <div>) has its own purpose • If you use older browsers, use modernizr or add the elements via JavaScript to the DOM
  • 18. main { display: block; } aside > nav { display: -ms-flex; -ms-flex-flow: row wrap; flex-flow: row wrap; } • Layout in HTML is done by a combination of HTML <tags> and CSS {styles} • Don’t position your elements by using <br/> or <p/> tags • CSS • Hardest part • Add a reset CSS to your page • reset.css or normalize.css • Use a Grid System to make this easier for you • 960grid • Twitter bootstrap • …
  • 19.
  • 20. • {display:block;} to have a newline before and after the element • {display:inline;} to put the element inside text or another element • {display:inline-block;} to have an inline element with features of a block element like width and height • {display:table;} to create table in CSS instead of HTML <div style="display: table;"> <div style="display: table-row;"> <div style="display: table-cell;"> </div> </div> </div>
  • 21. • {display:flex;}• • • • .flex { width: 525px; height: 300px; border: 1px solid #000000; display: flex; flex-direction: row; } .flex > div { flex: 1 1 auto; } .flex > div:nth-child(1) { background: #000000; } .flex > div:nth-child(2) { background: #f3f32f; } .flex > div:nth-child(3) { background: #ff0000; }
  • 22.
  • 23.
  • 24. • Make it easier to work with styles • Make it possible to make styles use variables
  • 25.
  • 26.
  • 27. • No easy way to maintain large CSS Stylesheets • SOLUTION: CSS Precompilers • SASS • LESS • Stylus • CSS Crush • …
  • 28. @techdays-color: rgb(255,188,0); @techdays-darkerColor: (@vision-color + #111); body{ background-color: @vision-color; border: 1px solid @vision-darkerColor; }
  • 29. @width: 960px; .middle{ width: @width * 2 / 3; } .left, .right{ width: @width / 6; }
  • 30. header{ background-color: orange; nav{ background-color: darken(orange, 10%); } nav a{ text-decoration: none; &:hover{text-decoration: underline;} } } header {background-color: orange;} header nav {background-color: #cc8400;} header nav a {text-decoration: none;} header nav a:hover {text-decoration: underline;}
  • 31.
  • 32. • Blocks of UI elements that can be reused • Limited to properties of elements • Are tied to type for which they are defined <Grid> <Grid.Resources> <Style TargetType="Rectangle" x:Key="Outlined"> <Setter Property="StrokeThickness" Value="2" /> <Setter Property="Stroke" Value="Black"/> </Style> </Grid.Resources> <Rectangle Fill="#FF808080" Width="100" Height="50" Style="{StaticResource Outlined}" StrokeThickness="5" /> </Grid>
  • 33. • Should have name and TargetType defined • TargetType is polymorphic • Static or dynamic (only in WPF) • Aren’t really cascading, although we can build a hierarchy of styles • Similar to CSS <Style x:Key="BaseControl" TargetType="Control"> <Setter Property="FontWeight" Value="Bold" /> </Style> <Style x:Key="ButtonStyle1" TargetType="Button" BasedOn="{StaticResource BaseControl}"> <Setter Property="FontFamily" Value="Verdana" /> <Setter Property="FontSize" Value="18" /> </Style>
  • 34. • Inside a style setter, we can do data-binding • Not really a variable though • How it works: • Create an object • Bind a style to it • When the object changes, the bound values in the setters will also change
  • 36.
  • 37.
  • 39.
  • 40. • All drawing is vector-based • No problems with different resolution • Based on hierarchy of shapes • Shape base class • Rectangle • Ellipse • Line • Polygon • Polyline • Path
  • 41. • Basic properties • Fill • Stroke • Width • Height • Opacity • Visibility • Cursor (depending on platform)
  • 42. • Shapes can have fill and stroke • Brushes • SolidColorBrush • LinearGradientBrush • RadialGradientBrush • ImageBrush • VideoBrush (depending on platform) Fill Stroke
  • 43. <Path Stroke="Black" StrokeThickness="2"> <Path.Data> <PathGeometry> <PathGeometry.Figures> <PathFigure StartPoint="5,25"> <PathFigure.Segments> <BezierSegment Point1="25,0" Point2="75,50" Point3="95,25" /> </PathFigure.Segments> </PathFigure> </PathGeometry.Figures> </PathGeometry> </Path.Data> </Path>
  • 44.
  • 45. • Is not so easy, but great things can be achieved • Posibilities • Canvas • SVG • WebGL • Plain Old JavaScript • Which option you pick, JavaScript needs to be your friend • Or you should try CSS3D
  • 46. • Typical choice for most HTML games • Simple • But fast • Bitmapped area, so drawn objects become part of the canvas which makes it impossible to attach event handlers • When objects move, you must redraw the canvas
  • 47. • XML based vector graphics format • Less performant but very flexible • Each drawn object becomes part of the DOM • Attach one or more event handlers to it <svg width="320" height="320"> <defs> <radialGradient id="circleGrad"> <stop offset="100%" stop-color="rgb( 0, 255, 0)" /> </radialGradient> </defs> <ellipse fill="url(#circleGrad)" stroke="#000" cx="50%“ cy="50%" rx="50%" ry="50%"> </ellipse> </svg>
  • 48.
  • 49.
  • 50. • Offer simple way to store user data locally
  • 51.
  • 52. • If you want to store data locally, you can choose between these options • Cookies (which I will not explain) • LocalStorage / SessionStorage • IndexedDB • WebSQL
  • 53. • SessionStorage • Temporary key/value pairs • 1 session per tab/windows • LocalStorage • Same as session storage but persistant • Global usage in multiple instances of your browser localStorage.setItem("rememberMeForALongTime", anyObject); sessionStorage.setItem("rememberMeForALittleWhile", anyObject); var anyObject = sessionStorage.getItem("rememberMeForALittleWhile"); var anyObject = localStorage.getItem("rememberMeForALongTime");
  • 54. • API for client-side storage of data • Local and session storage is good for small amounts of data • IndexedDB is ideal for large amounts of data • Transactional database System • Boost performance by using indexes
  • 55.
  • 56.
  • 57. • Silverlight and Windows Phone define IsolatedStorage • Can store data on Client Machine • Size of storage is quota'd • Mostly used to save state/settings
  • 58. // Get the Store and Stream using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication()) using (IsolatedStorageFileStream stream = file.CreateFile("Foo.config")) { // Save Some Data StreamWriter writer = new StreamWriter(stream); writer.WriteLine("AutoRun=true"); writer.Flush(); stream.Close(); }
  • 59. // Get the Store and Stream using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication()) using (IsolatedStorageFileStream stream = file.OpenFile("Foo.config", FileMode.Open)) { // Read Some Data StreamReader rdr = new StreamReader(stream); string config = rdr.ReadToEnd(); stream.Close(); }
  • 60. • Simple usage to create Application Settings • Use IsolatedStorageSettings to set/get settings • ApplicationSettings are per .xap • SiteSettings are per domain IsolatedStorageSettings.ApplicationSettings["foo"] = "bar"; string appFoo = IsolatedStorageSettings.ApplicationSettings["foo"] as string; IsolatedStorageSettings.SiteSettings["foo"] = "bar"; string siteFoo = IsolatedStorageSettings.SiteSettings["foo"] as string;
  • 61. • Defines Application Data API • Local • Roaming • Temporary • Based on • File system • Settings (automatically persisted)
  • 62. Local Local folder Roaming Synced folder Temp Temp (local) folder Local Settings (Registry) Synced Settings
  • 63.
  • 64.
  • 65. • Access (relational) data behind a service • RESTful interaction with the service
  • 66.
  • 67. • Silverlight, Windows 8 and Windows Phone share server-technologies that they can communicate with • ASMX • WCF • REST • RSS • Sockets • oData • … • Common requirement is asynchronous communication • Silverlight: callbacks • Windows 8 and Windows Phone 8: await/async pattern • Note: WPF can use the full, raw power of .NET and thus has even less restrictions
  • 68. • Defines HttpClient (Silverlight and WP7 used WebClient) • Works async • HttpClient defines • Get(Async) • Returns an HttpResponseMessage • Put(Async) • Post(Async) • Delete(Async) RESTful! • Windows 8.1 introduced a new version of the HttpClient • Very similar API
  • 69. • XML • Linq-To-XML • XmlReader/XmlWriter • XmlSerializer • JSON: • Use the JsonObject and feed it the returned string • DataContractJsonSerializer is also available • JSON.NET • Open source via NuGet • Often the preferred choice
  • 70.
  • 71. • If you want to retrieve data in a browser you have following options • XMLHttpRequest • WebSockets
  • 72. • XMLHttpRequest defines an API for transferring data between a client and a server • Client initiates the request • Synchronous or Asynchronous • Based on the HTTP protocol var xhr = new XMLHttpRequest(); xhr.open("GET", "URL", /*async*/ true); xhr.onreadystatechange = function () { if (xhr.readyState == COMPLETE) { if (xhr.status == 200) { var data = xhr.responseText; } } } xhr.send();
  • 73. • API for socket connections between a browser and a server • 2-way persistant connection between client and server • Event-driven responses • Send messages to the server and receive a response without polling the server
  • 74. var socket = new WebSocket("ws://www.mi6.com/socketserver", "yourprotocol"); function sendJamesBondOnASecretMission() { var msg = { type: "message", mission: document.getElementById("mission").value, id: clientID, date: Date.now() }; socket.send(JSON.stringify(msg)); } socket.onmessage = function (event) { var data = event.data; }
  • 75.
  • 76.
  • 77. • Don’t require us to write code like TextBox1.Text = Person1.FirstName; • Support two-way binding mode
  • 78.
  • 79. • HTML does not know the concept of data binding • You have data and you bind it to a control • Plenty of JavaScript frameworks available to allow datavbinding in HTML • Knockout • Angular • Mustache • … • Depending on the framework, the syntax may be different
  • 80. <ul data-bind="foreach: secretAgents"> <li class="secretAgent"> <header> <span data-bind="text: Name"></span> </header> <img data-bind="attr: {alt: name, id: id, src:img}" /> </li> </ul> viewModel = { memories: ko.observableArray(items), }; ko.applyBindings(viewModel);
  • 81. <script id="secretAgents" type="text/html"> <ul> {{#secretAgent}} <li>{{name}}</li> {{/secretAgent}} </ul> </script> $(function () { $.getJSON('@Url.Action("SecretAgents", "MI6")', function (data) { var html = Mustache.to_html($("#secretAgents").html(),{quotes: data }); $("#secretAgents").empty().append(html); }) });
  • 82.
  • 83. • Infrastructure for binding control properties to objects and collections • Loosely-coupled model, already exists in ASP.NET, WinForms • Simple and powerful model • Source • Any Object • PropertyPath • Path To Any Public Property • Dynamic • Supports multiple Binding Models • OneTime, OneWay and TwoWay
  • 85. • Binding Syntax • Markup Extension • PropertyPath at a minimum • Or specify Source • Most often: use a DataContext on a base control <TextBox Text="{Binding Name}" /> <Grid.Resources> <local:Person x:Key="person1" /> </Grid.Resources> ... <TextBox Text="{Binding Name, Source={StaticResource person1}}" /> <Grid DataContext={StaticResource person1}> <TextBox Text="{Binding Name}" /> </Grid>
  • 86. • Three Modes for Binding • TwoWay, OneWay or OneTime • Binding Syntax for Mode • Binding Syntax • OneWay and OneTime work with any object • Property Based Reads • TwoWay works with any objects • Property Based Writes <TextBlock Content="{Binding Name, Mode=TwoWay}" />
  • 87. • Binding Interfaces • Properties use INotifyPropertyChanged interface • Collections use INotifyCollectionChanged interface • Use ObservableCollection<> for Bindable Collections
  • 88.
  • 89.
  • 90. • Easy way of media playback • Support for common formats • DRM
  • 91.
  • 92. • MediaElement Loads or Streams content • Loading: • Plays Media as Progressively Downloaded • Streamed: • Downloads Chunk and plays it • Support for • Audio • MP3 • Wav • Video • MP4 • WMV • OGG video • Support for • Scrubbing • Markers (subtitles) <MediaElement x:Name="MainMediaElement" Height="300" Width="640" AreTransportControlsEnabled="True" />
  • 93. • Silverlight, Windows Phone and Windows 8 support DRM • Player Framework • PlayReady Client • Smooth Streaming SDK
  • 94.
  • 95. • Audio and Video are already available for years • But it was kind of difficult
  • 96. • Now, it is much more simple to add media
  • 97. • But sometimes, codecs can be a pain
  • 98. function playPauseVideo() { if (video.paused || video.ended) { if (video.ended) { video.currentTime = 0; } video.play(); } else { video.pause(); } }
  • 99.
  • 100.
  • 101. • Rich, native control set • Basic • Advanced • Extensible control set • Data visualizations
  • 102.
  • 103. • HTML does not have a rich set of built-in controls • And part of these controls are not supported by all browsers • Built-in in HTML: • TextBox • PasswordBox • Slider • Progress • Calendar • DatePicker • …
  • 104. • Because of the open web community you can download code to create extra controls
  • 105. • Because of the open web community you can download code to create extra controls
  • 106. • Or you can download or buy extra controls • jQuery UI • Kendo UI
  • 107.
  • 108. • Very rich control set • Depending on technology • Built-in in most XAML technologies • TextBox • PasswordBox • Slider • ProgressBar • Calendar • DatePicker • …
  • 109. • Content controls can contain other content • One child • Nested • Controls • Button • CheckBox • RadioButton • TabControl • ScrollViewer • … <Button> <Button.Content> <StackPanel> <Image Source="pain.jpg" Width="100" /> <TextBlock TextAlignment="Center" Text="Click Me" /> </StackPanel> </Button.Content> </Button>
  • 110. • Bindable to IList or IEnumerable lists • ItemsControl • ListBox • ComboBox (not in W8 and WP8) • TabControl (not in W8 and WP8) • DataGrid (not in W8 and WP8) • Inherit from ItemsControl • Similar to a repeater <ItemsControl> <Button Content="Click One" /> <Button Content="Click Two" /> </ItemsControl>
  • 111. • Endless options when you start to template controls • Allows re-definition of build-in controls • Can redefine the XAML that is used to build control • Look can be changed dramatically by changing XAML • Feel can be changed • Can only add built-in behavior • E.g. no new methods, properties or events
  • 112.
  • 113.
  • 114. • Support • Classes • Interfaces • Inheritance • Polymorphism
  • 115.
  • 116. • It’s C#  • XAML does know about OO principles going on behind the scenes • DataTemplateSelectors • Implicit Data Templates • Data binding properties
  • 117.
  • 118. • Although lots of people thing that you cannot do OO stuff in JavaScript, you can • It is not always pretty, but it is possible JamesBond = (function() { function JamesBond(name, drink) { this.name = name; this.drink = drink; } return JamesBond; })(); sean = new JamesBond("Sean Connery", "Martini");
  • 119. • Although lots of people thing that you cannot do OO stuff in JavaScript, you can • It is not always pretty, but it is possible JamesBond = (function() { function JamesBond(name, drink) { this.name = name; this.drink = drink; } return JamesBond; })(); sean = new JamesBond("Sean Connery", "Martini");
  • 120. • Today: make your live easier with compilers/transpilers/… • CoffeeScript • TypeScript • … # CoffeeScript class JamesBond constructor: (name, drink) -> @name = name @drink = drink // TypeScript class JamesBond{ name: string;drink: string; constructor(name: string, drink: string) { this.name = name; this.drink = drink; } }
  • 121. • ECMAScript 6 will add more OO functionality • Future version of JavaScript
  • 122.
  • 123.
  • 124. • Support an easy way for unit testing • Unit testing frameworks
  • 125.
  • 126. • Bunch of Testing Frameworks available • QUnit • Mocha • TestSwarm • Jasmine • Tutti • … • Ideal with a JavaScript build system like grunt or gulp
  • 127.
  • 128. • Silverlight includes support for unit testing directly from Visual Studio • Run in the browser • Not easy to integrate with build process • In general, not a great story! • Windows 8 support Unit Test Library template in Visual Studio • Based on Visual Studio Testing Framework • Integrates with build process • Other unit testing frameworks are supports