SlideShare una empresa de Scribd logo
1 de 25
© Copyright SELA software & Education Labs Ltd. | 14-18 Baruch Hirsch St Bnei Brak, 51202 Israel | www.selagroup.com
SELA DEVELOPER PRACTICE
JUNE 29 – JULY 3, 2014
Michael Haberman
From XAML / C# to HTML5 / JS
How to transition???
Don’t be scared
Lets take our knowledge and experience to HTML JS
Mainly MVVM
The difference
Lots of libraries (AngularJS,Jquery, BackBone, Knockout)
Doesn’t compile
Doesn’t have MVVM Features
Lots of libraries – 20 MVVM Frameworks ?!
The difference
Lots of libraries (AngularJS,Jquery, BackBone, Knockout)
Doesn’t compile
Doesn’t have MVVM Features
Type Script – lets make it compile!
Compiles your Javascript Code!!
Compile time errors
Intellisense
The difference
Lots of libraries (AngularJS,Jquery, BackBone, Knockout)
Doesn’t compile
Doesn’t have MVVM Features
What MVVM Feature do we want?
Data Binding
Converter
Mode
INotifyPropertyChanged
Command
Passing a parameter
Context Binding
Comparison
XAML Knockout
Property changes Implement
INotfiyPropertyChanged
Use KnockoutObservable
Collection changes Implement
INotifyCollectionChanged
Use KnockoutObservableArray
Command Implement ICommand Access any method
Convert data Converter Computed
Binding Inline logic X V
Collection Iterate ItemsControl using DataTemplate Foreach binding using template
Access parent/root ViewModel Relative binding using
RelativeSource
$parent / $root
Access another UI Element ElementBinding $element
Demo
Lets see how to setup the environment
Setting DataContext
Knockout
C#
var vm = new MySampleAPP.MainViewModel()
ko.applyBindings(vm);
DataContext = new MainViewModel();
Binding an element
XAML
<TextBlock Text="{Binding FirstName}"/>
Knockout
<input type="text" data-bind="value: FirstName"/>
Visibility bound to ViewModel
KnockoutXAML
data-bind="if: HasLoggedinUser”
OR
data-bind="visible: Status() == 'Working'"
Visibility="{Binding HasLoggedinUser, Converter={StaticResource Converter}}"/>
Commands
XAMLKnockout
<Button Command="{Binding ChangeUser}"/><input type="button" data-bind="click: ChangeUser, valueUpdate:'input'"/>
Update Options
XAML Knockout
Default Afterkeydown
PropertyChanged Keyup
LostFocus Keypress
Explicit Input
Change
Iterate through collections - XAML
<ItemsControl ItemsSource="{Binding Collection}" >
<TextBlock Text="{Binding Name}"/>
</ItemsControl>
Knockout collections
Like ObservableCollection<T>
public Employees: KnockoutObservableArray<Employee> = ko.observableArray([]);
Iterate thought collections - Knockout
<table data-bind="if: HasLoggedinUser">
<tbody data-bind="foreach: Employees">
<tr>
<td><span data-bind="text: Name"></span></td>
</tr>
</tbody>
</table>
New style converters
Another way to update the UI via ViewModel’s Logic
self.SalaryState = ko.computed(() => {
…
return “red”;
});
<span data-bind="text: Salary, style: { color: SalaryState()}" ></span>
Context binding - Knockout
Within foreach access to ViewModel and passing the current
item as parameter
<input type="button" value="Delete" data-bind="click: $parent.DeleteEmployee" />
Knockout context binding
Similar to relative source or element binding:
$parent - $parent[indexer]
$root
$element
Comparison
XAML Knockout
Property changes Implement
INotfiyPropertyChanged
Use KnockoutObservable
Collection changes Implement
INotifyCollectionChanged
Use KnockoutObservableArray
Command Implement ICommand Access any method
Convert data Converter Computed
Binding Inline logic X V
Collection Iterate ItemsControl using DataTemplate Foreach binding using template
Access parent/root ViewModel Relative binding using
RelativeSource
$parent / $root
Access another UI Element ElementBinding $element
The difference
Lots of libraries (AngularJS,Jquery, BackBone, Knockout)
Doesn’t compile
Doesn’t have MVVM Features
Summary
HTML5 + JS + Knockout isn’t scary!
Knockout provide an easy transition
for XAML developers
Go home and try it your self!
Questions

Más contenido relacionado

La actualidad más candente

Mvc presentation
Mvc presentationMvc presentation
Mvc presentation
MaslowB
 
Canopy view of single-page applications (SPAs)
Canopy view of single-page applications (SPAs)Canopy view of single-page applications (SPAs)
Canopy view of single-page applications (SPAs)
Benjamin Howarth
 

La actualidad más candente (20)

Wijmo 5 - GrapeCity Echo Tokyo
Wijmo 5 - GrapeCity Echo TokyoWijmo 5 - GrapeCity Echo Tokyo
Wijmo 5 - GrapeCity Echo Tokyo
 
Asp.net mvc basic introduction
Asp.net mvc basic introductionAsp.net mvc basic introduction
Asp.net mvc basic introduction
 
Single Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJSSingle Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJS
 
Building databound JavaScript apps with Knockoutjs
Building databound JavaScript apps with KnockoutjsBuilding databound JavaScript apps with Knockoutjs
Building databound JavaScript apps with Knockoutjs
 
Mvc presentation
Mvc presentationMvc presentation
Mvc presentation
 
Comparative analysis of java script framework
Comparative analysis of java script frameworkComparative analysis of java script framework
Comparative analysis of java script framework
 
KnockoutJS and MVVM
KnockoutJS and MVVMKnockoutJS and MVVM
KnockoutJS and MVVM
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
 
Asp.net mvc 4
Asp.net mvc 4Asp.net mvc 4
Asp.net mvc 4
 
Canopy view of single-page applications (SPAs)
Canopy view of single-page applications (SPAs)Canopy view of single-page applications (SPAs)
Canopy view of single-page applications (SPAs)
 
ASP.NET MVC and ajax
ASP.NET MVC and ajax ASP.NET MVC and ajax
ASP.NET MVC and ajax
 
Modern Applications With Asp.net Core 5 and Vue JS 3
Modern Applications With Asp.net Core 5 and Vue JS 3Modern Applications With Asp.net Core 5 and Vue JS 3
Modern Applications With Asp.net Core 5 and Vue JS 3
 
MVVM & Validation with Kendo UI
MVVM & Validation with Kendo UIMVVM & Validation with Kendo UI
MVVM & Validation with Kendo UI
 
ASP.NET MVC 3
ASP.NET MVC 3ASP.NET MVC 3
ASP.NET MVC 3
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVC Introduction to ASP.NET MVC
Introduction to ASP.NET MVC
 
The RAW stack
The RAW stackThe RAW stack
The RAW stack
 
Os mobile
Os mobileOs mobile
Os mobile
 
Mvc
MvcMvc
Mvc
 
Easy HTML5 Data Visualization with Kendo UI DataViz
Easy HTML5 Data Visualization with Kendo UI DataVizEasy HTML5 Data Visualization with Kendo UI DataViz
Easy HTML5 Data Visualization with Kendo UI DataViz
 
Os mobile
Os mobileOs mobile
Os mobile
 

Similar a XAML/C# to HTML5/JS

Javascript frameworks: Backbone.js
Javascript frameworks: Backbone.jsJavascript frameworks: Backbone.js
Javascript frameworks: Backbone.js
Soós Gábor
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
Fabio Franzini
 
Backbone introdunction
Backbone introdunctionBackbone introdunction
Backbone introdunction
mzxbupt
 

Similar a XAML/C# to HTML5/JS (20)

Knockoutjs
KnockoutjsKnockoutjs
Knockoutjs
 
Viking academy backbone.js
Viking academy  backbone.jsViking academy  backbone.js
Viking academy backbone.js
 
Javascript frameworks: Backbone.js
Javascript frameworks: Backbone.jsJavascript frameworks: Backbone.js
Javascript frameworks: Backbone.js
 
Knockoutjs databinding
Knockoutjs databindingKnockoutjs databinding
Knockoutjs databinding
 
Knockout.js
Knockout.jsKnockout.js
Knockout.js
 
Fundaments of Knockout js
Fundaments of Knockout jsFundaments of Knockout js
Fundaments of Knockout js
 
Backbone js in action
Backbone js in actionBackbone js in action
Backbone js in action
 
Bringing the light to the client with KnockoutJS
Bringing the light to the client with KnockoutJSBringing the light to the client with KnockoutJS
Bringing the light to the client with KnockoutJS
 
MV* presentation frameworks in Javascript: en garde, pret, allez!
MV* presentation frameworks in Javascript: en garde, pret, allez!MV* presentation frameworks in Javascript: en garde, pret, allez!
MV* presentation frameworks in Javascript: en garde, pret, allez!
 
Real world #microservices with Apache Camel, Fabric8, and OpenShift
Real world #microservices with Apache Camel, Fabric8, and OpenShiftReal world #microservices with Apache Camel, Fabric8, and OpenShift
Real world #microservices with Apache Camel, Fabric8, and OpenShift
 
Real-world #microservices with Apache Camel, Fabric8, and OpenShift
Real-world #microservices with Apache Camel, Fabric8, and OpenShiftReal-world #microservices with Apache Camel, Fabric8, and OpenShift
Real-world #microservices with Apache Camel, Fabric8, and OpenShift
 
Knockoutjs
KnockoutjsKnockoutjs
Knockoutjs
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVC
 
Backbone js
Backbone jsBackbone js
Backbone js
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
Red Hat Agile integration Workshop Labs
Red Hat Agile integration Workshop LabsRed Hat Agile integration Workshop Labs
Red Hat Agile integration Workshop Labs
 
e-suap - client technologies- english version
e-suap - client technologies- english versione-suap - client technologies- english version
e-suap - client technologies- english version
 
Protocol-Oriented MVVM (extended edition)
Protocol-Oriented MVVM (extended edition)Protocol-Oriented MVVM (extended edition)
Protocol-Oriented MVVM (extended edition)
 
Backbone introdunction
Backbone introdunctionBackbone introdunction
Backbone introdunction
 
Knockout Basics By Surekha Gadkari
Knockout Basics By Surekha GadkariKnockout Basics By Surekha Gadkari
Knockout Basics By Surekha Gadkari
 

Más de Michael Haberman

Más de Michael Haberman (15)

Deploying microservices on AWS
Deploying microservices on AWSDeploying microservices on AWS
Deploying microservices on AWS
 
Angular universal
Angular universalAngular universal
Angular universal
 
React in production
React in productionReact in production
React in production
 
Multiplayer game with angular and firebase
Multiplayer game with angular and firebaseMultiplayer game with angular and firebase
Multiplayer game with angular and firebase
 
How to: node js & micro-services
How to: node js & micro-servicesHow to: node js & micro-services
How to: node js & micro-services
 
Javascript issues and tools in production for developers
Javascript issues and tools in production for developersJavascript issues and tools in production for developers
Javascript issues and tools in production for developers
 
AWS Serverless solution for developers
AWS Serverless solution for developersAWS Serverless solution for developers
AWS Serverless solution for developers
 
Angular 4 - quick view
Angular 4 - quick viewAngular 4 - quick view
Angular 4 - quick view
 
React vs angular (mobile first battle)
React vs angular (mobile first battle)React vs angular (mobile first battle)
React vs angular (mobile first battle)
 
React vs-angular-mobile
React vs-angular-mobileReact vs-angular-mobile
React vs-angular-mobile
 
MEAN.js Workshop
MEAN.js WorkshopMEAN.js Workshop
MEAN.js Workshop
 
AWS intro
AWS introAWS intro
AWS intro
 
Angular Unit Test
Angular Unit TestAngular Unit Test
Angular Unit Test
 
Unit-testing and E2E testing in JS
Unit-testing and E2E testing in JSUnit-testing and E2E testing in JS
Unit-testing and E2E testing in JS
 
XAML/C# to HTML/JS
XAML/C# to HTML/JSXAML/C# to HTML/JS
XAML/C# to HTML/JS
 

Último

Último (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 

XAML/C# to HTML5/JS

  • 1. © Copyright SELA software & Education Labs Ltd. | 14-18 Baruch Hirsch St Bnei Brak, 51202 Israel | www.selagroup.com SELA DEVELOPER PRACTICE JUNE 29 – JULY 3, 2014 Michael Haberman From XAML / C# to HTML5 / JS
  • 2. How to transition??? Don’t be scared Lets take our knowledge and experience to HTML JS Mainly MVVM
  • 3. The difference Lots of libraries (AngularJS,Jquery, BackBone, Knockout) Doesn’t compile Doesn’t have MVVM Features
  • 4. Lots of libraries – 20 MVVM Frameworks ?!
  • 5. The difference Lots of libraries (AngularJS,Jquery, BackBone, Knockout) Doesn’t compile Doesn’t have MVVM Features
  • 6. Type Script – lets make it compile! Compiles your Javascript Code!! Compile time errors Intellisense
  • 7. The difference Lots of libraries (AngularJS,Jquery, BackBone, Knockout) Doesn’t compile Doesn’t have MVVM Features
  • 8. What MVVM Feature do we want? Data Binding Converter Mode INotifyPropertyChanged Command Passing a parameter Context Binding
  • 9. Comparison XAML Knockout Property changes Implement INotfiyPropertyChanged Use KnockoutObservable Collection changes Implement INotifyCollectionChanged Use KnockoutObservableArray Command Implement ICommand Access any method Convert data Converter Computed Binding Inline logic X V Collection Iterate ItemsControl using DataTemplate Foreach binding using template Access parent/root ViewModel Relative binding using RelativeSource $parent / $root Access another UI Element ElementBinding $element
  • 10. Demo Lets see how to setup the environment
  • 11. Setting DataContext Knockout C# var vm = new MySampleAPP.MainViewModel() ko.applyBindings(vm); DataContext = new MainViewModel();
  • 12. Binding an element XAML <TextBlock Text="{Binding FirstName}"/> Knockout <input type="text" data-bind="value: FirstName"/>
  • 13. Visibility bound to ViewModel KnockoutXAML data-bind="if: HasLoggedinUser” OR data-bind="visible: Status() == 'Working'" Visibility="{Binding HasLoggedinUser, Converter={StaticResource Converter}}"/>
  • 14. Commands XAMLKnockout <Button Command="{Binding ChangeUser}"/><input type="button" data-bind="click: ChangeUser, valueUpdate:'input'"/>
  • 15. Update Options XAML Knockout Default Afterkeydown PropertyChanged Keyup LostFocus Keypress Explicit Input Change
  • 16. Iterate through collections - XAML <ItemsControl ItemsSource="{Binding Collection}" > <TextBlock Text="{Binding Name}"/> </ItemsControl>
  • 17. Knockout collections Like ObservableCollection<T> public Employees: KnockoutObservableArray<Employee> = ko.observableArray([]);
  • 18. Iterate thought collections - Knockout <table data-bind="if: HasLoggedinUser"> <tbody data-bind="foreach: Employees"> <tr> <td><span data-bind="text: Name"></span></td> </tr> </tbody> </table>
  • 19. New style converters Another way to update the UI via ViewModel’s Logic self.SalaryState = ko.computed(() => { … return “red”; }); <span data-bind="text: Salary, style: { color: SalaryState()}" ></span>
  • 20. Context binding - Knockout Within foreach access to ViewModel and passing the current item as parameter <input type="button" value="Delete" data-bind="click: $parent.DeleteEmployee" />
  • 21. Knockout context binding Similar to relative source or element binding: $parent - $parent[indexer] $root $element
  • 22. Comparison XAML Knockout Property changes Implement INotfiyPropertyChanged Use KnockoutObservable Collection changes Implement INotifyCollectionChanged Use KnockoutObservableArray Command Implement ICommand Access any method Convert data Converter Computed Binding Inline logic X V Collection Iterate ItemsControl using DataTemplate Foreach binding using template Access parent/root ViewModel Relative binding using RelativeSource $parent / $root Access another UI Element ElementBinding $element
  • 23. The difference Lots of libraries (AngularJS,Jquery, BackBone, Knockout) Doesn’t compile Doesn’t have MVVM Features
  • 24. Summary HTML5 + JS + Knockout isn’t scary! Knockout provide an easy transition for XAML developers Go home and try it your self!