29 Core XAML

What’s In This Chapter?

  • XAML syntax
  • Dependency properties
  • Routed events
  • Attached properties
  • Markup extensions

Wrox.com Code Downloads for This Chapter

The wrox.com code downloads for this chapter are found at www.wrox.com/go/professionalcsharp6 on the Download Code tab. The code for this chapter is divided into the following major examples, for both WPF and Universal Windows apps:

  • Code Intro
  • XAML Intro
  • Dependency Objects
  • Routed Events
  • Attached Properties
  • Markup Extensions

Uses of XAML

When you’re writing a .NET application, usually C# is not the only syntax you need to know. If you write Universal Windows apps, Windows desktop applications using Windows Presentation Foundation (WPF), or workflows with Windows Workflow Foundation (WF); create XPS documents, or write Silverlight apps, you also need XAML. XAML (eXtensible Application Markup Language) is a declarative XML syntax that’s usually needed with these applications. This chapter describes the syntax of XAML and the extensibility mechanisms that are available with this markup language. The chapter describes the differences between XAML in WPF applications and Windows apps using the Universal Windows Platform (UWP).

All that can be done with XAML can also be done with C#—so why is there a need for XAML? XAML is typically used to describe objects and their properties, and this is possible in a deep hierarchy. For example, a Window control contains a Grid control; the Grid control contains a StackPanel

Get Professional C# 6 and .NET Core 1.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.