SlideShare a Scribd company logo
1 of 32
Consulting/Training
My XML is Alive! (An Intro to XAML)
Consulting/Training
consulting
Wintellect helps you build better software,
faster, tackling the tough projects and solving
the software and technology questions that
help you transform your business.
 Architecture, Analysis and Design
 Full lifecycle software development
 Debugging and Performance tuning
 Database design and development
training
Wintellect's courses are written and taught by
some of the biggest and most respected names
in the Microsoft programming industry.
 Learn from the best. Access the same
training Microsoft’s developers enjoy
 Real world knowledge and solutions on
both current and cutting edge
technologies
 Flexibility in training options – onsite,
virtual, on demand
Founded by top experts on Microsoft – Jeffrey Richter, Jeff Prosise, and John Robbins – we pull
out all the stops to help our customers achieve their goals through advanced software-based
consulting and training solutions.
who we are
About Wintellect
Consulting/Training
 Imperative to Declare
 XAML
 Data-binding
 Notify Property Change
 Design-time Data
 The Visual Tree
 Value Converters
 Dependency Objects and Properties
 Attached Properties and Behaviors
 The Visual State Manager
 MVVM
Agenda
Consulting/Training
 Imperative programming is the traditional
approach to writing code. You just … write it.
 Declarative programming lets you focus more
on structure or tasks and leaves the solution to
the compiler (or interpreter, or runtime).
 Imperative is more testable and gives you more
control over the implementation details.
 Declarative tends to be more readable and
accessible to non-developers (such as
designers).
Imperative to Declare
Consulting/Training
// imperative (long)
var productNames = new List<string>();
foreach(var p in Products)
{
if (p.Price <= 9.99)
{
productNames.Add(p.ProductName);
}
}
// a little of both (short with LINQ)
var productNames =
from p in Products
where p.Price <= 9.99
select p.ProductName;
// declarative (long with LINQ)
var productNames = Products.Where(p => p.Price <= 9.99).Select(p => p.ProductName);
Example of Imperative vs. Declarative
How to filter the product
How to project the product name
What to filter
What to project
Consulting/Training
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="myBindingConfiguration" closeTimeout="00:01:00" />
</basicHttpBinding>
</bindings>
<services>
<service name="MyNamespace.myServiceType">
<endpoint
address="myAddress" binding="basicHttpBinding"
bindingConfiguration="myBindingConfiguration"
contract="MyContract" />
</service>
</services>
</system.serviceModel>
</configuration>
WCF can be Declarative…
What, what, and what
Consulting/Training
BasicHttpBinding myBinding = new BasicHttpBinding();
EndpointAddress myEndpoint = new EndpointAddress("myAddress");
ChannelFactory<MyContract> myChannelFactory = new
ChannelFactory<MyContract>(myBinding, myEndpoint);
MyContract wcfClient = myChannelFactory.CreateChannel();
…or WCF can be Imperative
How, how, how …
Consulting/Training
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>I Hereby Declare</title>
<meta name="description" content="I Hereby Declare">
<meta name="author" content="Jeremy Likness">
<link rel="stylesheet" href="css/styles.css">
</head>
<body>
<h1>This is the Heading</h1>
<p>Can you get a sense of the structure from this?
</body>
</html>
HTML is Declarative…
Consulting/Training
<?xml version="1.0">
<note>
<to>Jeremy Likness</to>
<from>Me</from>
<body>Do not forget to show the XML example.</body>
</note>
…and so is XML
Consulting/Training
 eXtensible Application Markup Language
 Pronounced “Zammel” (rhymes with “Camel”)
 An open specification by Microsoft
 XAML *is* XML
 Instantiates classes and initializes values and properties
 Used in WPF, Silverlight (including Windows Phone
apps), Windows Workflow Foundation, and the
Windows Runtime
 XML  CLR (or WinRT) that is language independent
 The same XAML can be used whether you are writing
your imperative code in C#, VB.NET, or even C++
XAML
Consulting/Training
Calculator
Consulting/Training
 XAML instantiates classes
 XAML populates properties
 UI Elements can be declared with XAML
 UI Elements have a special feature called “data-
binding”
 Data-binding can be used to view data
 Anything that can be declared in XAML can be
written with code!
What Did We Learn?
Consulting/Training
var page = new Page();
var grid = new Grid();
page.Content = new Grid();
var textBlock = new TextBlock();
var binding = new Binding
{
Path = new PropertyPath("Result")
};
textBlock.SetBinding(TextBlock.TextProperty, binding);
grid.Children.Add(textBlock);
grid.DataContext = new object(); // calculator here
XAML  Code
Consulting/Training
<TextBlock
Style="{StaticResource HeaderTextStyle}"
Text="{Binding Path=Result}"/>
Quick Decomposition
Create an instance of the
TextBlock WinRT component
Set the Style property of the
TextBlock
Moustaches are for markup
extensions. They will instantiate
the “StaticResource” class and
pass the “HeaderTextStyle”
parameter
This one uses a named parameter with the
special Binding markup extension. Binding is
what makes XAML magic for UI.
Consulting/Training
Data-Binding
Source (Data)
Target
(Framework
Element)
Data-Binding
Component
One-Way One-Way
Two-Way
Consulting/Training
Data-Binding
Consulting/Training
Data-Binding
Consulting/Training
 Simple interface to implement on your class
 Whenever you want data-binding to “know”
about changes (typically whenever a property
is updated) you raise an event with the
property name
 Empty property name means “all properties are
suspect”
 Also similar interface and events for collections
(observable collections)
Notify Property Change
Consulting/Training
 Very powerful – you don’t want to “design in
the dark”
 You can implement this several ways, including
“design-aware classes”
 Visual Studio 2013 has support for data files
(such as JSON)
 Specify a data source and type, or an instance
and “is design-time creatable”
Design-time Data
Consulting/Training
The Visual Tree
Consulting/Training
Value Converters
Consulting/Training
 Helps separate the data from the information (the
raw “stuff” from the presentation)
 Takes in one value, spits out another value
 Works equally well on primitives and complex
types
 Typically one way (for presentation) however can
be both ways in case you want to take user input
and map it back to an internal instance
 Avoid things like string-formatting, data
preparation, etc. in your model, instead use the
built-in XAML constructs to do this in the view
Value Converters
Consulting/Training
 Provides the “dependency property system”
designed to compute values of properties from
multiple sources (XAML configuration, animations,
styles, data-binding, etc.) and provide system
notification when values have changed
 Properties are registered with the system and
exposes as CLR properties that pass information
back and forth to the underlying object
 Common base for most XAML UI elements – allows
them to bind to each other, to data sources, etc.
 Provides inheritance, i.e. “data context” can be set
at a parent level and propagate to children
Dependency Objects and Properties
Consulting/Training
Attached Properties
Consulting/Training
 Used to extend functionality or apply a common
behavior to existing elements
 For example, an element doesn’t “know” about grid
rows and columns, but attached properties extend
elements to allow them to specify what cells to appear
in when a grid is rendered
 If you find you are performing a common operation
(such as listening to text change events to update
data-bindings) consider encapsulating in a behavior
 Behaviors are independently testable and then
reusable and can be applied across existing elements
 Use dependency properties to save/recall values
Attached Properties and Behaviors
Consulting/Training
The Visual State Manager
Consulting/Training
 Again helps to separate the UI from the code
logic
 Declarative way to map states to their visual
representation
 Rich support for animations
 Transitions to emphasize the shift between
states
 Orthogonal groups
 Mutually exclusive states
The Visual State Manager
Consulting/Training
Model-View-ViewModel (MVVM)
Consulting/Training
 At the basic level means you have a class that
exposes properties for data-binding and holds the
state of the presentation
 Commands are a special type of data-bound
“action”
 Plenty of libraries but WinRT XAML has plenty to
support it “out of the box”
 Don’t be afraid of code-behind when it relates to
the UI (presentation) piece – after all, it is just an
extension of the classes that are declared by XAML
 Reuse across platforms (phone, Windows 8, etc.)
Model-View-ViewModel
Consulting/Training
 Imperative to Declare
 XAML
 Data-binding
 Notify Property Change
 Design-time Data
 The Visual Tree
 Value Converters
 Dependency Objects and Properties
 Attached Properties and Behaviors
 The Visual State Manager
 MVVM
Recap
Consulting/Training
Subscribers Enjoy
 Expert Instructors
 Quality Content
 Practical Application
 All Devices
Wintellect’s On-Demand
Video Training Solution
Individuals | Businesses | Enterprise Organizations
WintellectNOW.com
Authors Enjoy
 Royalty Income
 Personal Branding
 Free Library Access
 Cross-Sell
Opportunities
Try It Free!
Use Promo Code:
LIKNESS-13
Consulting/Training
Questions?
jlikness@Wintellect.com
Source Code:
http://bit.ly/16ScWyM

More Related Content

What's hot

The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...SPTechCon
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVCLearnNowOnline
 
ASP .NET MVC
ASP .NET MVC ASP .NET MVC
ASP .NET MVC eldorina
 
Principles of MVC for PHP Developers
Principles of MVC for PHP DevelopersPrinciples of MVC for PHP Developers
Principles of MVC for PHP DevelopersEdureka!
 
MVC Puree - Approaches to MVC with Umbraco
MVC Puree - Approaches to MVC with UmbracoMVC Puree - Approaches to MVC with Umbraco
MVC Puree - Approaches to MVC with UmbracoAndy Butland
 
Angular JS, A dive to concepts
Angular JS, A dive to conceptsAngular JS, A dive to concepts
Angular JS, A dive to conceptsAbhishek Sur
 
3-TIER ARCHITECTURE IN ASP.NET MVC
3-TIER ARCHITECTURE IN ASP.NET MVC3-TIER ARCHITECTURE IN ASP.NET MVC
3-TIER ARCHITECTURE IN ASP.NET MVCMohd Manzoor Ahmed
 
Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016Marco Breveglieri
 
ASP.net MVC Introduction Wikilogia (nov 2014)
ASP.net MVC Introduction Wikilogia (nov 2014)ASP.net MVC Introduction Wikilogia (nov 2014)
ASP.net MVC Introduction Wikilogia (nov 2014)Hatem Hamad
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVC Introduction to ASP.NET MVC
Introduction to ASP.NET MVC Joe Wilson
 
MVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on RailsMVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on Railscodeinmotion
 
The Web on Windows
The Web on WindowsThe Web on Windows
The Web on WindowsJosh Lane
 
HTML5: the new frontier of the web
HTML5: the new frontier of the webHTML5: the new frontier of the web
HTML5: the new frontier of the webIvano Malavolta
 

What's hot (20)

ASP .NET MVC - best practices
ASP .NET MVC - best practicesASP .NET MVC - best practices
ASP .NET MVC - best practices
 
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
 
ASP .NET MVC
ASP .NET MVC ASP .NET MVC
ASP .NET MVC
 
ASP.NET MVC for Begineers
ASP.NET MVC for BegineersASP.NET MVC for Begineers
ASP.NET MVC for Begineers
 
Knockout js
Knockout jsKnockout js
Knockout js
 
ASP .net MVC
ASP .net MVCASP .net MVC
ASP .net MVC
 
Principles of MVC for PHP Developers
Principles of MVC for PHP DevelopersPrinciples of MVC for PHP Developers
Principles of MVC for PHP Developers
 
MVC Puree - Approaches to MVC with Umbraco
MVC Puree - Approaches to MVC with UmbracoMVC Puree - Approaches to MVC with Umbraco
MVC Puree - Approaches to MVC with Umbraco
 
Angular JS, A dive to concepts
Angular JS, A dive to conceptsAngular JS, A dive to concepts
Angular JS, A dive to concepts
 
3-TIER ARCHITECTURE IN ASP.NET MVC
3-TIER ARCHITECTURE IN ASP.NET MVC3-TIER ARCHITECTURE IN ASP.NET MVC
3-TIER ARCHITECTURE IN ASP.NET MVC
 
Azure and Umbraco CMS
Azure and Umbraco CMSAzure and Umbraco CMS
Azure and Umbraco CMS
 
Mvc4
Mvc4Mvc4
Mvc4
 
Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016
 
ASP.net MVC Introduction Wikilogia (nov 2014)
ASP.net MVC Introduction Wikilogia (nov 2014)ASP.net MVC Introduction Wikilogia (nov 2014)
ASP.net MVC Introduction Wikilogia (nov 2014)
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVC Introduction to ASP.NET MVC
Introduction to ASP.NET MVC
 
MVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on RailsMVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on Rails
 
ASP.NET MVC 3
ASP.NET MVC 3ASP.NET MVC 3
ASP.NET MVC 3
 
The Web on Windows
The Web on WindowsThe Web on Windows
The Web on Windows
 
HTML5: the new frontier of the web
HTML5: the new frontier of the webHTML5: the new frontier of the web
HTML5: the new frontier of the web
 

Viewers also liked

Angular from a Different Angle
Angular from a Different AngleAngular from a Different Angle
Angular from a Different AngleJeremy Likness
 
Advanced AngularJS Tips and Tricks
Advanced AngularJS Tips and TricksAdvanced AngularJS Tips and Tricks
Advanced AngularJS Tips and TricksJeremy Likness
 
Let's Build an Angular App!
Let's Build an Angular App!Let's Build an Angular App!
Let's Build an Angular App!Jeremy Likness
 
Angle Forward with TypeScript
Angle Forward with TypeScriptAngle Forward with TypeScript
Angle Forward with TypeScriptJeremy Likness
 
C# Async/Await Explained
C# Async/Await ExplainedC# Async/Await Explained
C# Async/Await ExplainedJeremy Likness
 
Back to the ng2 Future
Back to the ng2 FutureBack to the ng2 Future
Back to the ng2 FutureJeremy Likness
 
Cross-Platform Agile DevOps with Visual Studio Team Services
Cross-Platform Agile DevOps with Visual Studio Team ServicesCross-Platform Agile DevOps with Visual Studio Team Services
Cross-Platform Agile DevOps with Visual Studio Team ServicesJeremy Likness
 

Viewers also liked (7)

Angular from a Different Angle
Angular from a Different AngleAngular from a Different Angle
Angular from a Different Angle
 
Advanced AngularJS Tips and Tricks
Advanced AngularJS Tips and TricksAdvanced AngularJS Tips and Tricks
Advanced AngularJS Tips and Tricks
 
Let's Build an Angular App!
Let's Build an Angular App!Let's Build an Angular App!
Let's Build an Angular App!
 
Angle Forward with TypeScript
Angle Forward with TypeScriptAngle Forward with TypeScript
Angle Forward with TypeScript
 
C# Async/Await Explained
C# Async/Await ExplainedC# Async/Await Explained
C# Async/Await Explained
 
Back to the ng2 Future
Back to the ng2 FutureBack to the ng2 Future
Back to the ng2 Future
 
Cross-Platform Agile DevOps with Visual Studio Team Services
Cross-Platform Agile DevOps with Visual Studio Team ServicesCross-Platform Agile DevOps with Visual Studio Team Services
Cross-Platform Agile DevOps with Visual Studio Team Services
 

Similar to My XML is Alive! An Intro to XAML

No more Three Tier - A path to a better code for Cloud and Azure
No more Three Tier - A path to a better code for Cloud and AzureNo more Three Tier - A path to a better code for Cloud and Azure
No more Three Tier - A path to a better code for Cloud and AzureMarco Parenzan
 
Be a database professional
Be a database professionalBe a database professional
Be a database professionalSayed Ahmed
 
Be a database professional
Be a database professionalBe a database professional
Be a database professionalSayed Ahmed
 
Data modeling star schema
Data modeling star schemaData modeling star schema
Data modeling star schemaSayed Ahmed
 
Silverlight Developer Introduction
Silverlight   Developer IntroductionSilverlight   Developer Introduction
Silverlight Developer IntroductionTomy Ismail
 
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...Bill Buchan
 
MPhil Lecture of Data Vis for Presentation
MPhil Lecture of Data Vis for PresentationMPhil Lecture of Data Vis for Presentation
MPhil Lecture of Data Vis for PresentationShawn Day
 
Building appsinsilverlight4 part_1
Building appsinsilverlight4 part_1Building appsinsilverlight4 part_1
Building appsinsilverlight4 part_1Dennis Perlot
 
WinRT and the Web: Keeping Windows Store Apps Alive and Connected
WinRT and the Web: Keeping Windows Store Apps Alive and ConnectedWinRT and the Web: Keeping Windows Store Apps Alive and Connected
WinRT and the Web: Keeping Windows Store Apps Alive and ConnectedJeremy Likness
 
Azure vs AWS
Azure vs AWSAzure vs AWS
Azure vs AWSJosh Lane
 
Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...
Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...
Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...Karen Thompson
 
What is struts_en
What is struts_enWhat is struts_en
What is struts_entechbed
 
Elements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code FirstElements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code FirstEnea Gabriel
 
Drools & jBPM Info Sheet
Drools & jBPM Info SheetDrools & jBPM Info Sheet
Drools & jBPM Info SheetMark Proctor
 

Similar to My XML is Alive! An Intro to XAML (20)

No more Three Tier - A path to a better code for Cloud and Azure
No more Three Tier - A path to a better code for Cloud and AzureNo more Three Tier - A path to a better code for Cloud and Azure
No more Three Tier - A path to a better code for Cloud and Azure
 
Introducing Oslo
Introducing OsloIntroducing Oslo
Introducing Oslo
 
Be a database professional
Be a database professionalBe a database professional
Be a database professional
 
Be a database professional
Be a database professionalBe a database professional
Be a database professional
 
Data modeling star schema
Data modeling star schemaData modeling star schema
Data modeling star schema
 
Silverlight Developer Introduction
Silverlight   Developer IntroductionSilverlight   Developer Introduction
Silverlight Developer Introduction
 
Fundaments of Knockout js
Fundaments of Knockout jsFundaments of Knockout js
Fundaments of Knockout js
 
RavenDB overview
RavenDB overviewRavenDB overview
RavenDB overview
 
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
 
MPhil Lecture of Data Vis for Presentation
MPhil Lecture of Data Vis for PresentationMPhil Lecture of Data Vis for Presentation
MPhil Lecture of Data Vis for Presentation
 
Building appsinsilverlight4 part_1
Building appsinsilverlight4 part_1Building appsinsilverlight4 part_1
Building appsinsilverlight4 part_1
 
WinRT and the Web: Keeping Windows Store Apps Alive and Connected
WinRT and the Web: Keeping Windows Store Apps Alive and ConnectedWinRT and the Web: Keeping Windows Store Apps Alive and Connected
WinRT and the Web: Keeping Windows Store Apps Alive and Connected
 
Azure vs AWS
Azure vs AWSAzure vs AWS
Azure vs AWS
 
Data vault what's Next: Part 2
Data vault what's Next: Part 2Data vault what's Next: Part 2
Data vault what's Next: Part 2
 
Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...
Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...
Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...
 
What is struts_en
What is struts_enWhat is struts_en
What is struts_en
 
Elements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code FirstElements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code First
 
Drools & jBPM Info Sheet
Drools & jBPM Info SheetDrools & jBPM Info Sheet
Drools & jBPM Info Sheet
 
Intro to Application Express
Intro to Application ExpressIntro to Application Express
Intro to Application Express
 
12363 database certification
12363 database certification12363 database certification
12363 database certification
 

Recently uploaded

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 

Recently uploaded (20)

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 

My XML is Alive! An Intro to XAML

  • 1. Consulting/Training My XML is Alive! (An Intro to XAML)
  • 2. Consulting/Training consulting Wintellect helps you build better software, faster, tackling the tough projects and solving the software and technology questions that help you transform your business.  Architecture, Analysis and Design  Full lifecycle software development  Debugging and Performance tuning  Database design and development training Wintellect's courses are written and taught by some of the biggest and most respected names in the Microsoft programming industry.  Learn from the best. Access the same training Microsoft’s developers enjoy  Real world knowledge and solutions on both current and cutting edge technologies  Flexibility in training options – onsite, virtual, on demand Founded by top experts on Microsoft – Jeffrey Richter, Jeff Prosise, and John Robbins – we pull out all the stops to help our customers achieve their goals through advanced software-based consulting and training solutions. who we are About Wintellect
  • 3. Consulting/Training  Imperative to Declare  XAML  Data-binding  Notify Property Change  Design-time Data  The Visual Tree  Value Converters  Dependency Objects and Properties  Attached Properties and Behaviors  The Visual State Manager  MVVM Agenda
  • 4. Consulting/Training  Imperative programming is the traditional approach to writing code. You just … write it.  Declarative programming lets you focus more on structure or tasks and leaves the solution to the compiler (or interpreter, or runtime).  Imperative is more testable and gives you more control over the implementation details.  Declarative tends to be more readable and accessible to non-developers (such as designers). Imperative to Declare
  • 5. Consulting/Training // imperative (long) var productNames = new List<string>(); foreach(var p in Products) { if (p.Price <= 9.99) { productNames.Add(p.ProductName); } } // a little of both (short with LINQ) var productNames = from p in Products where p.Price <= 9.99 select p.ProductName; // declarative (long with LINQ) var productNames = Products.Where(p => p.Price <= 9.99).Select(p => p.ProductName); Example of Imperative vs. Declarative How to filter the product How to project the product name What to filter What to project
  • 6. Consulting/Training <?xml version="1.0" encoding="utf-8"?> <configuration> <system.serviceModel> <bindings> <basicHttpBinding> <binding name="myBindingConfiguration" closeTimeout="00:01:00" /> </basicHttpBinding> </bindings> <services> <service name="MyNamespace.myServiceType"> <endpoint address="myAddress" binding="basicHttpBinding" bindingConfiguration="myBindingConfiguration" contract="MyContract" /> </service> </services> </system.serviceModel> </configuration> WCF can be Declarative… What, what, and what
  • 7. Consulting/Training BasicHttpBinding myBinding = new BasicHttpBinding(); EndpointAddress myEndpoint = new EndpointAddress("myAddress"); ChannelFactory<MyContract> myChannelFactory = new ChannelFactory<MyContract>(myBinding, myEndpoint); MyContract wcfClient = myChannelFactory.CreateChannel(); …or WCF can be Imperative How, how, how …
  • 8. Consulting/Training <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>I Hereby Declare</title> <meta name="description" content="I Hereby Declare"> <meta name="author" content="Jeremy Likness"> <link rel="stylesheet" href="css/styles.css"> </head> <body> <h1>This is the Heading</h1> <p>Can you get a sense of the structure from this? </body> </html> HTML is Declarative…
  • 9. Consulting/Training <?xml version="1.0"> <note> <to>Jeremy Likness</to> <from>Me</from> <body>Do not forget to show the XML example.</body> </note> …and so is XML
  • 10. Consulting/Training  eXtensible Application Markup Language  Pronounced “Zammel” (rhymes with “Camel”)  An open specification by Microsoft  XAML *is* XML  Instantiates classes and initializes values and properties  Used in WPF, Silverlight (including Windows Phone apps), Windows Workflow Foundation, and the Windows Runtime  XML  CLR (or WinRT) that is language independent  The same XAML can be used whether you are writing your imperative code in C#, VB.NET, or even C++ XAML
  • 12. Consulting/Training  XAML instantiates classes  XAML populates properties  UI Elements can be declared with XAML  UI Elements have a special feature called “data- binding”  Data-binding can be used to view data  Anything that can be declared in XAML can be written with code! What Did We Learn?
  • 13. Consulting/Training var page = new Page(); var grid = new Grid(); page.Content = new Grid(); var textBlock = new TextBlock(); var binding = new Binding { Path = new PropertyPath("Result") }; textBlock.SetBinding(TextBlock.TextProperty, binding); grid.Children.Add(textBlock); grid.DataContext = new object(); // calculator here XAML  Code
  • 14. Consulting/Training <TextBlock Style="{StaticResource HeaderTextStyle}" Text="{Binding Path=Result}"/> Quick Decomposition Create an instance of the TextBlock WinRT component Set the Style property of the TextBlock Moustaches are for markup extensions. They will instantiate the “StaticResource” class and pass the “HeaderTextStyle” parameter This one uses a named parameter with the special Binding markup extension. Binding is what makes XAML magic for UI.
  • 18. Consulting/Training  Simple interface to implement on your class  Whenever you want data-binding to “know” about changes (typically whenever a property is updated) you raise an event with the property name  Empty property name means “all properties are suspect”  Also similar interface and events for collections (observable collections) Notify Property Change
  • 19. Consulting/Training  Very powerful – you don’t want to “design in the dark”  You can implement this several ways, including “design-aware classes”  Visual Studio 2013 has support for data files (such as JSON)  Specify a data source and type, or an instance and “is design-time creatable” Design-time Data
  • 22. Consulting/Training  Helps separate the data from the information (the raw “stuff” from the presentation)  Takes in one value, spits out another value  Works equally well on primitives and complex types  Typically one way (for presentation) however can be both ways in case you want to take user input and map it back to an internal instance  Avoid things like string-formatting, data preparation, etc. in your model, instead use the built-in XAML constructs to do this in the view Value Converters
  • 23. Consulting/Training  Provides the “dependency property system” designed to compute values of properties from multiple sources (XAML configuration, animations, styles, data-binding, etc.) and provide system notification when values have changed  Properties are registered with the system and exposes as CLR properties that pass information back and forth to the underlying object  Common base for most XAML UI elements – allows them to bind to each other, to data sources, etc.  Provides inheritance, i.e. “data context” can be set at a parent level and propagate to children Dependency Objects and Properties
  • 25. Consulting/Training  Used to extend functionality or apply a common behavior to existing elements  For example, an element doesn’t “know” about grid rows and columns, but attached properties extend elements to allow them to specify what cells to appear in when a grid is rendered  If you find you are performing a common operation (such as listening to text change events to update data-bindings) consider encapsulating in a behavior  Behaviors are independently testable and then reusable and can be applied across existing elements  Use dependency properties to save/recall values Attached Properties and Behaviors
  • 27. Consulting/Training  Again helps to separate the UI from the code logic  Declarative way to map states to their visual representation  Rich support for animations  Transitions to emphasize the shift between states  Orthogonal groups  Mutually exclusive states The Visual State Manager
  • 29. Consulting/Training  At the basic level means you have a class that exposes properties for data-binding and holds the state of the presentation  Commands are a special type of data-bound “action”  Plenty of libraries but WinRT XAML has plenty to support it “out of the box”  Don’t be afraid of code-behind when it relates to the UI (presentation) piece – after all, it is just an extension of the classes that are declared by XAML  Reuse across platforms (phone, Windows 8, etc.) Model-View-ViewModel
  • 30. Consulting/Training  Imperative to Declare  XAML  Data-binding  Notify Property Change  Design-time Data  The Visual Tree  Value Converters  Dependency Objects and Properties  Attached Properties and Behaviors  The Visual State Manager  MVVM Recap
  • 31. Consulting/Training Subscribers Enjoy  Expert Instructors  Quality Content  Practical Application  All Devices Wintellect’s On-Demand Video Training Solution Individuals | Businesses | Enterprise Organizations WintellectNOW.com Authors Enjoy  Royalty Income  Personal Branding  Free Library Access  Cross-Sell Opportunities Try It Free! Use Promo Code: LIKNESS-13

Editor's Notes

  1. Author Opportunity Passive incomeClear marketing commitments to help grow your personal brand and your coursesInternational presence &amp; exposureCross sell opportunities – instructor led classes, consulting opportunities, and conference speaking opportunitiesOpportunity to be the subject matter expert and to carve out a niche for yourself in this new businessAssociation with Wintellect