SlideShare a Scribd company logo
© 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

More Related Content

What's hot (20)

PPTX
Wijmo 5 - GrapeCity Echo Tokyo
Chris Bannon
 
PDF
Asp.net mvc basic introduction
Bhagath Gopinath
 
PPTX
Single Page Application (SPA) using AngularJS
M R Rony
 
PPTX
Building databound JavaScript apps with Knockoutjs
Nish Anil
 
PPTX
Mvc presentation
MaslowB
 
PPT
Comparative analysis of java script framework
Nishant Kumar
 
PPT
KnockoutJS and MVVM
Manvendra Singh
 
PPT
Introduction to ASP.NET MVC
Sunpawet Somsin
 
PPTX
Asp.net mvc 4
Hrichi Mohamed
 
PPTX
Canopy view of single-page applications (SPAs)
Benjamin Howarth
 
PPTX
ASP.NET MVC and ajax
Brij Mishra
 
PPTX
Modern Applications With Asp.net Core 5 and Vue JS 3
Alexandre Malavasi
 
PPTX
MVVM & Validation with Kendo UI
Lohith Goudagere Nagaraj
 
PDF
ASP.NET MVC 3
Buu Nguyen
 
PPTX
Introduction to ASP.NET MVC
Joe Wilson
 
PPTX
The RAW stack
Maurice De Beijer [MVP]
 
PPT
Os mobile
jimlindforpope
 
ODP
Mvc
abhigad
 
PDF
Easy HTML5 Data Visualization with Kendo UI DataViz
Lohith Goudagere Nagaraj
 
PPT
Os mobile
jimlindforpope
 
Wijmo 5 - GrapeCity Echo Tokyo
Chris Bannon
 
Asp.net mvc basic introduction
Bhagath Gopinath
 
Single Page Application (SPA) using AngularJS
M R Rony
 
Building databound JavaScript apps with Knockoutjs
Nish Anil
 
Mvc presentation
MaslowB
 
Comparative analysis of java script framework
Nishant Kumar
 
KnockoutJS and MVVM
Manvendra Singh
 
Introduction to ASP.NET MVC
Sunpawet Somsin
 
Asp.net mvc 4
Hrichi Mohamed
 
Canopy view of single-page applications (SPAs)
Benjamin Howarth
 
ASP.NET MVC and ajax
Brij Mishra
 
Modern Applications With Asp.net Core 5 and Vue JS 3
Alexandre Malavasi
 
MVVM & Validation with Kendo UI
Lohith Goudagere Nagaraj
 
ASP.NET MVC 3
Buu Nguyen
 
Introduction to ASP.NET MVC
Joe Wilson
 
Os mobile
jimlindforpope
 
Mvc
abhigad
 
Easy HTML5 Data Visualization with Kendo UI DataViz
Lohith Goudagere Nagaraj
 
Os mobile
jimlindforpope
 

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

PDF
Knockoutjs
Yourcontent YC
 
PDF
Viking academy backbone.js
Bert Wijnants
 
ODP
Javascript frameworks: Backbone.js
Soós Gábor
 
PDF
Knockoutjs databinding
Boulos Dib
 
PPTX
Knockout.js
Vivek Rajan
 
PPTX
Fundaments of Knockout js
Flavius-Radu Demian
 
PDF
Backbone js in action
Usha Guduri
 
PPTX
Bringing the light to the client with KnockoutJS
Boyan Mihaylov
 
PPTX
MV* presentation frameworks in Javascript: en garde, pret, allez!
Roberto Messora
 
PPTX
Real-world #microservices with Apache Camel, Fabric8, and OpenShift
Christian Posta
 
PPTX
Real world #microservices with Apache Camel, Fabric8, and OpenShift
Christian Posta
 
PPTX
Knockoutjs
Karthik Sathyanarayanan
 
PDF
Backbone.js — Introduction to client-side JavaScript MVC
pootsbook
 
PPT
Backbone js
Knoldus Inc.
 
PDF
WebNet Conference 2012 - Designing complex applications using html5 and knock...
Fabio Franzini
 
PDF
Red Hat Agile integration Workshop Labs
Judy Breedlove
 
PPTX
e-suap - client technologies- english version
Sabino Labarile
 
PDF
Protocol-Oriented MVVM (extended edition)
Natasha Murashev
 
PPT
Backbone introdunction
mzxbupt
 
PPT
Knockout Basics By Surekha Gadkari
Surekha Gadkari
 
Knockoutjs
Yourcontent YC
 
Viking academy backbone.js
Bert Wijnants
 
Javascript frameworks: Backbone.js
Soós Gábor
 
Knockoutjs databinding
Boulos Dib
 
Knockout.js
Vivek Rajan
 
Fundaments of Knockout js
Flavius-Radu Demian
 
Backbone js in action
Usha Guduri
 
Bringing the light to the client with KnockoutJS
Boyan Mihaylov
 
MV* presentation frameworks in Javascript: en garde, pret, allez!
Roberto Messora
 
Real-world #microservices with Apache Camel, Fabric8, and OpenShift
Christian Posta
 
Real world #microservices with Apache Camel, Fabric8, and OpenShift
Christian Posta
 
Backbone.js — Introduction to client-side JavaScript MVC
pootsbook
 
Backbone js
Knoldus Inc.
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
Fabio Franzini
 
Red Hat Agile integration Workshop Labs
Judy Breedlove
 
e-suap - client technologies- english version
Sabino Labarile
 
Protocol-Oriented MVVM (extended edition)
Natasha Murashev
 
Backbone introdunction
mzxbupt
 
Knockout Basics By Surekha Gadkari
Surekha Gadkari
 
Ad

More from Michael Haberman (15)

PPTX
Deploying microservices on AWS
Michael Haberman
 
PPTX
Angular universal
Michael Haberman
 
PPTX
React in production
Michael Haberman
 
PPTX
Multiplayer game with angular and firebase
Michael Haberman
 
PPTX
How to: node js & micro-services
Michael Haberman
 
PDF
Javascript issues and tools in production for developers
Michael Haberman
 
PPTX
AWS Serverless solution for developers
Michael Haberman
 
PPTX
Angular 4 - quick view
Michael Haberman
 
PDF
React vs angular (mobile first battle)
Michael Haberman
 
PDF
React vs-angular-mobile
Michael Haberman
 
PPTX
MEAN.js Workshop
Michael Haberman
 
PPTX
AWS intro
Michael Haberman
 
PPTX
Angular Unit Test
Michael Haberman
 
PDF
Unit-testing and E2E testing in JS
Michael Haberman
 
PDF
XAML/C# to HTML/JS
Michael Haberman
 
Deploying microservices on AWS
Michael Haberman
 
Angular universal
Michael Haberman
 
React in production
Michael Haberman
 
Multiplayer game with angular and firebase
Michael Haberman
 
How to: node js & micro-services
Michael Haberman
 
Javascript issues and tools in production for developers
Michael Haberman
 
AWS Serverless solution for developers
Michael Haberman
 
Angular 4 - quick view
Michael Haberman
 
React vs angular (mobile first battle)
Michael Haberman
 
React vs-angular-mobile
Michael Haberman
 
MEAN.js Workshop
Michael Haberman
 
AWS intro
Michael Haberman
 
Angular Unit Test
Michael Haberman
 
Unit-testing and E2E testing in JS
Michael Haberman
 
XAML/C# to HTML/JS
Michael Haberman
 
Ad

Recently uploaded (20)

PDF
introduction to computer hardware and sofeware
chauhanshraddha2007
 
PDF
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
PDF
The Future of Artificial Intelligence (AI)
Mukul
 
PPTX
Agile Chennai 18-19 July 2025 | Workshop - Enhancing Agile Collaboration with...
AgileNetwork
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PDF
Market Insight : ETH Dominance Returns
CIFDAQ
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PPTX
Simple and concise overview about Quantum computing..pptx
mughal641
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PPTX
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PDF
Researching The Best Chat SDK Providers in 2025
Ray Fields
 
PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
PDF
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PDF
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
introduction to computer hardware and sofeware
chauhanshraddha2007
 
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
The Future of Artificial Intelligence (AI)
Mukul
 
Agile Chennai 18-19 July 2025 | Workshop - Enhancing Agile Collaboration with...
AgileNetwork
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
Market Insight : ETH Dominance Returns
CIFDAQ
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
Simple and concise overview about Quantum computing..pptx
mughal641
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
Researching The Best Chat SDK Providers in 2025
Ray Fields
 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
The Future of AI & Machine Learning.pptx
pritsen4700
 

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!