SlideShare a Scribd company logo
DesigningWindows
Apps withXAML
Jiri Danihelka
What is XAML?
• XAML – eXtensible Application Markup Language
• Object instantiation and property setting
• Define UI in declarative fashion
XAML Namespaces
1
2
3
4
5
1. Maps the overall XAML client / framework as the default namespace
2. Maps common programming constructs and data intrinsics to the x: namespace – x:Name, x:Boolean, etc.
3. Maps the current app C# namespace to local:
4. Maps the Blend namespace to d:
5. Maps the Markup Compatibility to mc:
Allows the use of mc:ignorable to prevent the XAML processor raising errors on namespaces
Common x: constructs
Term Description
x:Key Unique key for an entry in a resource dictionary
x:Class Specifies the code namespace and class name fro the code-behind for a XAML page
x:Name Specifies the instance name for the object created when a XAML element is processed at
run-time. Essentially creates a backing variable with the name.
x:Uid Identifies elements that use localized resources
x:Bind New for Windows 10 and is an alternative to {Binding}
XAML Intrinsic Types The types that can be used for simple value-types in resources – i.e.
• x:Boolean
• x:String
• x:Null
Markup Extensions
Term Description
{Binding} Supports data binding
{StaticResource} References resources defined in a Resource Dictionary
{ThemeResource} Similar to {StaticResource} but can respond to run-time theme changes
{TemplateBinding} A special type of {Binding} that supports control templates
{RelativeSource} Allows template bindings to reference values from the templated parent
{CustomResource} Enables advanced resource lookup scenarios
• Elements
• Containers
• Properties
• Attached Properties
• Collection Syntax
XAML Syntax
XAML Code
XAML vs Code
Why do we need layout controls?
• Manual positioning / Fixed layout are not responsive
• Layout is a result of interaction between parent and child
elements:
– Parent to Child: “How much space do you want?”
– Child to Parent: “I would like (width, height) based on my content”
– Parent considers constraints and other children…
– Parent to Child: “You have (width1, height1) at location (x,y)”
• Different layout controls apply different constraints
Child Layout Properties
• Input
– Height & Width – try to avoid setting explicitly
– MinHeight & MinWidth
– MaxHeight & MaxWidth
• Output
– DesiredSize – calculated during layout
– RenderSize* – size after layout is complete
– ActualHeight & ActualWidth* – height and width from RenderSize
• Note: Elements try to render as small as possible
* Only safe to rely on in LayoutUpdated
Child Layout Properties
• HorizontalAlignment
– Left, Center, Right and Stretch
• VerticalAlignment
– Top, Center, Bottom and Stretch
• Configures element alignment within their parent
Child Layout Properties
• HorizontalContentAlignment
– Left, Center, Right and Stretch
• VerticalContentAlignment
– Top, Center, Bottom and Stretch
• Configures content alignment within the element
Child Layout Properties
• Margin
– All FrameworkElements
– Controls space around the *outside* of the element
• Padding
– All Controls
– Controls space around the *inside* of the element
• Visibility – Visible & Collapsed
– Collapsed elements have no size
– Collapsed elements are still instantiated
Child Layout Properties
No Parent Padding
Parent Padding
First Rectangle Margin
RenderTransforms
• Note that render transformations occur after layout, so they do
not impact their container sizing:
Layout Controls - Canvas
• Layout children using fixed positioning via attached properties:
– Canvas.Left & Canvas.Top
Layout Controls - StackPanel
• Arranges children in a simple line – either vertically or
horizontally
Layout Controls - Grid
• Arranges children in a multi-row
and multi-column layout
– Grid.Row, Grid.Column, Grid.RowSpan, Grid.ColumnSpan
Layout Controls - VariableSizedWrapGrid
Arranges elements in rows or columns
that wrap as needed or when the
MaximumRowsOrColumns is reached.
Layout Controls - RelativePanel
Arranges children relative to the panel and/or other elements
Recommended Resources
• https://dev.windows.com/
• MSDN Windows 10 XAML Overview
– https://msdn.microsoft.com/en-
us/library/windows/apps/mt185595.aspx

More Related Content

PPTX
Cs 371-lecture-02
PDF
Entity API in Drupal 8 (Drupal Tech Talk October 2014)
PDF
2015-04-11-PseudoConstants
PPTX
DSpace 4.2 XMLUI Theming
PPTX
Wpf-Xaml And Layout Basics
PDF
Flexbox, Grid and Sass
PPTX
Hibernate tutorial
Cs 371-lecture-02
Entity API in Drupal 8 (Drupal Tech Talk October 2014)
2015-04-11-PseudoConstants
DSpace 4.2 XMLUI Theming
Wpf-Xaml And Layout Basics
Flexbox, Grid and Sass
Hibernate tutorial

Similar to Designing Windows apps with Xaml (20)

PDF
[React Native] Lecture 4: Basic Elements and UI Layout by using FlexBox
PPTX
Introduction to Software - Coder Forge - John Mulhall
PDF
PPTX
ADF - Layout Managers and Skinning
PPTX
MTA css layouts
PDF
Advanced guide to develop ajax applications using dojo
PPTX
Introduction to silverlight control 3
PPT
ORM Concepts and JPA 2.0 Specifications
PPTX
Basics of expression blend4
PPT
Programming Terminology
PPTX
Hibernate
PPTX
Bootstrap SLIDES for web development course
PPTX
2. react - native: basic
PPTX
Mastering the Lightning Framework - Part 1
KEY
ZendCon 2011 UnCon Domain-Driven Design
PDF
Theming in React
PPT
gdg_workshop 4 on web development HTML & CSS
PPTX
css3.pptx
PPTX
JS Essence
PDF
Introduction to Responsive Web Development
[React Native] Lecture 4: Basic Elements and UI Layout by using FlexBox
Introduction to Software - Coder Forge - John Mulhall
ADF - Layout Managers and Skinning
MTA css layouts
Advanced guide to develop ajax applications using dojo
Introduction to silverlight control 3
ORM Concepts and JPA 2.0 Specifications
Basics of expression blend4
Programming Terminology
Hibernate
Bootstrap SLIDES for web development course
2. react - native: basic
Mastering the Lightning Framework - Part 1
ZendCon 2011 UnCon Domain-Driven Design
Theming in React
gdg_workshop 4 on web development HTML & CSS
css3.pptx
JS Essence
Introduction to Responsive Web Development
Ad

More from Jiri Danihelka (20)

PDF
Distributed Mobile Graphics
PPTX
Mixed reality for Windows 10
PPTX
New Xaml components for Windows developers
PPTX
MVVM Windows UWP apps with Template 10
PPTX
An introduction to development of universal applications
PPTX
Windows game development with Unity 5
PPTX
Creating great Unity games for Windows 10 - Part 2
PPTX
Creating great Unity games for Windows 10 - Part 1
PPTX
Prism library and MVVM
PPTX
UWP apps development - Part 3
PPTX
UWP apps development - Part 2
PPTX
UWP apps development - Part 1
PPTX
Advanced MVVM Windows UWP apps with Template 10
PPTX
Windows UX
PPTX
Blend for Visual Studio 2015
PPTX
Security misconfiguration
PPTX
Windows 10 Mobile and Distributed Graphics
PPTX
Security hardening and drown attack prevention for mobile backend developers
PPTX
Top 10 security risks for mobile backend developers
PPTX
Programování Windows 8
Distributed Mobile Graphics
Mixed reality for Windows 10
New Xaml components for Windows developers
MVVM Windows UWP apps with Template 10
An introduction to development of universal applications
Windows game development with Unity 5
Creating great Unity games for Windows 10 - Part 2
Creating great Unity games for Windows 10 - Part 1
Prism library and MVVM
UWP apps development - Part 3
UWP apps development - Part 2
UWP apps development - Part 1
Advanced MVVM Windows UWP apps with Template 10
Windows UX
Blend for Visual Studio 2015
Security misconfiguration
Windows 10 Mobile and Distributed Graphics
Security hardening and drown attack prevention for mobile backend developers
Top 10 security risks for mobile backend developers
Programování Windows 8
Ad

Recently uploaded (20)

PPTX
ANATOMY OF ANTERIOR CHAMBER ANGLE AND GONIOSCOPY.pptx
PPTX
AC-Unit1.pptx CRYPTOGRAPHIC NNNNFOR ALL
PDF
Key Trends in Website Development 2025 | B3AITS - Bow & 3 Arrows IT Solutions
PDF
High-frequency high-voltage transformer outline drawing
PPTX
Special finishes, classification and types, explanation
PPTX
Implications Existing phase plan and its feasibility.pptx
PPT
EGWHermeneuticsffgggggggggggggggggggggggggggggggg.ppt
PDF
YOW2022-BNE-MinimalViableArchitecture.pdf
PPTX
Tenders & Contracts Works _ Services Afzal.pptx
PPT
Machine printing techniques and plangi dyeing
PDF
Urban Design Final Project-Site Analysis
PPTX
6- Architecture design complete (1).pptx
PDF
SEVA- Fashion designing-Presentation.pdf
PDF
Urban Design Final Project-Context
PDF
Facade & Landscape Lighting Techniques and Trends.pptx.pdf
PDF
Africa 2025 - Prospects and Challenges first edition.pdf
PDF
Design Thinking - Module 1 - Introduction To Design Thinking - Dr. Rohan Dasg...
PDF
GREEN BUILDING MATERIALS FOR SUISTAINABLE ARCHITECTURE AND BUILDING STUDY
PDF
Phone away, tabs closed: No multitasking
PPTX
BSCS lesson 3.pptxnbbjbb mnbkjbkbbkbbkjb
ANATOMY OF ANTERIOR CHAMBER ANGLE AND GONIOSCOPY.pptx
AC-Unit1.pptx CRYPTOGRAPHIC NNNNFOR ALL
Key Trends in Website Development 2025 | B3AITS - Bow & 3 Arrows IT Solutions
High-frequency high-voltage transformer outline drawing
Special finishes, classification and types, explanation
Implications Existing phase plan and its feasibility.pptx
EGWHermeneuticsffgggggggggggggggggggggggggggggggg.ppt
YOW2022-BNE-MinimalViableArchitecture.pdf
Tenders & Contracts Works _ Services Afzal.pptx
Machine printing techniques and plangi dyeing
Urban Design Final Project-Site Analysis
6- Architecture design complete (1).pptx
SEVA- Fashion designing-Presentation.pdf
Urban Design Final Project-Context
Facade & Landscape Lighting Techniques and Trends.pptx.pdf
Africa 2025 - Prospects and Challenges first edition.pdf
Design Thinking - Module 1 - Introduction To Design Thinking - Dr. Rohan Dasg...
GREEN BUILDING MATERIALS FOR SUISTAINABLE ARCHITECTURE AND BUILDING STUDY
Phone away, tabs closed: No multitasking
BSCS lesson 3.pptxnbbjbb mnbkjbkbbkbbkjb

Designing Windows apps with Xaml

  • 2. What is XAML? • XAML – eXtensible Application Markup Language • Object instantiation and property setting • Define UI in declarative fashion
  • 3. XAML Namespaces 1 2 3 4 5 1. Maps the overall XAML client / framework as the default namespace 2. Maps common programming constructs and data intrinsics to the x: namespace – x:Name, x:Boolean, etc. 3. Maps the current app C# namespace to local: 4. Maps the Blend namespace to d: 5. Maps the Markup Compatibility to mc: Allows the use of mc:ignorable to prevent the XAML processor raising errors on namespaces
  • 4. Common x: constructs Term Description x:Key Unique key for an entry in a resource dictionary x:Class Specifies the code namespace and class name fro the code-behind for a XAML page x:Name Specifies the instance name for the object created when a XAML element is processed at run-time. Essentially creates a backing variable with the name. x:Uid Identifies elements that use localized resources x:Bind New for Windows 10 and is an alternative to {Binding} XAML Intrinsic Types The types that can be used for simple value-types in resources – i.e. • x:Boolean • x:String • x:Null
  • 5. Markup Extensions Term Description {Binding} Supports data binding {StaticResource} References resources defined in a Resource Dictionary {ThemeResource} Similar to {StaticResource} but can respond to run-time theme changes {TemplateBinding} A special type of {Binding} that supports control templates {RelativeSource} Allows template bindings to reference values from the templated parent {CustomResource} Enables advanced resource lookup scenarios
  • 6. • Elements • Containers • Properties • Attached Properties • Collection Syntax XAML Syntax
  • 8. Why do we need layout controls? • Manual positioning / Fixed layout are not responsive • Layout is a result of interaction between parent and child elements: – Parent to Child: “How much space do you want?” – Child to Parent: “I would like (width, height) based on my content” – Parent considers constraints and other children… – Parent to Child: “You have (width1, height1) at location (x,y)” • Different layout controls apply different constraints
  • 9. Child Layout Properties • Input – Height & Width – try to avoid setting explicitly – MinHeight & MinWidth – MaxHeight & MaxWidth • Output – DesiredSize – calculated during layout – RenderSize* – size after layout is complete – ActualHeight & ActualWidth* – height and width from RenderSize • Note: Elements try to render as small as possible * Only safe to rely on in LayoutUpdated
  • 10. Child Layout Properties • HorizontalAlignment – Left, Center, Right and Stretch • VerticalAlignment – Top, Center, Bottom and Stretch • Configures element alignment within their parent
  • 11. Child Layout Properties • HorizontalContentAlignment – Left, Center, Right and Stretch • VerticalContentAlignment – Top, Center, Bottom and Stretch • Configures content alignment within the element
  • 12. Child Layout Properties • Margin – All FrameworkElements – Controls space around the *outside* of the element • Padding – All Controls – Controls space around the *inside* of the element • Visibility – Visible & Collapsed – Collapsed elements have no size – Collapsed elements are still instantiated
  • 13. Child Layout Properties No Parent Padding Parent Padding First Rectangle Margin
  • 14. RenderTransforms • Note that render transformations occur after layout, so they do not impact their container sizing:
  • 15. Layout Controls - Canvas • Layout children using fixed positioning via attached properties: – Canvas.Left & Canvas.Top
  • 16. Layout Controls - StackPanel • Arranges children in a simple line – either vertically or horizontally
  • 17. Layout Controls - Grid • Arranges children in a multi-row and multi-column layout – Grid.Row, Grid.Column, Grid.RowSpan, Grid.ColumnSpan
  • 18. Layout Controls - VariableSizedWrapGrid Arranges elements in rows or columns that wrap as needed or when the MaximumRowsOrColumns is reached.
  • 19. Layout Controls - RelativePanel Arranges children relative to the panel and/or other elements
  • 20. Recommended Resources • https://dev.windows.com/ • MSDN Windows 10 XAML Overview – https://msdn.microsoft.com/en- us/library/windows/apps/mt185595.aspx