Presentation is loading. Please wait.

Presentation is loading. Please wait.

Windows Presentation Foundation (WPF) Chapter 16 Dr. Abraham.

Similar presentations


Presentation on theme: "Windows Presentation Foundation (WPF) Chapter 16 Dr. Abraham."— Presentation transcript:

1 Windows Presentation Foundation (WPF) Chapter 16 Dr. Abraham

2 WPF Microsoft’s new framework for GUI, graphics animation and multimedia. WPF generates vector-based graphics and is resolution independent. Building a GUI with WPF WPF uses XAML (Extensible Application Markup Language) to generate the code.

3 XAML When you use the designer, the IDE creates code to create and configure the controls In WPF, it generates XAML. You can manually write XAML to define GUI controls. When the application is compiled the XAML compiler generates code to create and configure controls. XAML allows designers and programmers to work together more efficiently.

4 Now to XML (before XAML)

5 XML TUTORIAL Portions from w3 schools By Dr. John Abraham

6 What is XML? XML stands for EXtensible Markup Language XML is a markup language much like HTML XML was designed to describe data XML tags are not predefined. You must define your own tags XML uses a Document Type Definition (DTD) or an XML Schema to describe the data XML with a DTD or XML Schema is designed to be self-descriptive XML is a W3C Recommendation - 1996

7 XML Portable, Widely supported, Open technology Standard for storing data (as text file) that are exchanged between applications. Not for displaying data No predefined tags – user supplies tags. With XML, financial information can be exchanged over the Internet

8 XML vs. HTML XML was designed to describe data and to focus on what data is. HTML was designed to display data and to focus on how data looks. HTML is about displaying information, while XML is about describing information XML can separate data from HTML

9 ARTICLE.XML file Simple XML December 6, 2001 John Doe XML is pretty easy. In this chapter, we present a wide variety of examples that use XML.

10 EXPLANATION Root element is article Child elements are title, data, author & summary To process this file, an XML parser is required, such as msxml (microsoft), Xerces (appache), etc.

11 XML rules All XML elements must have a closing tag –With XML, it is illegal to omit the closing tag. XML tags are case sensitive All XML elements must be properly nested. Following is wrong: – This text is bold and italic All XML documents must have a single root element

12 XML attributes XML elements can have attributes in the start tag, just like HTML. Attribute values must always be quoted Avoid using attributes if you can. Use child elements instead.

13 DTD A Document Type Definition defines the legal building blocks of an XML document. It defines the document structure with a list of legal elements. A "Valid" XML document also conforms to a DTD. A "Valid" XML document is a "Well Formed" XML document, which also conforms to the rules of a Document Type Definition (DTD) A DTD can be declared inline in your XML document, or as an external reference Your application can use a standard DTD to verify that the data you receive from the outside world is valid. You can also use a DTD to verify your own data.

14 Internal DTD <!DOCTYPE note [ ]> Tove Jani Reminder Don't forget me this weekend

15 This DTD is interpreted like this: !DOCTYPE note (in line 2) defines that this is a document of the type note. !ELEMENT note (in line 3) defines the note element as having four elements: "to,from,heading,body". !ELEMENT to (in line 4) defines the to element to be of the type "#PCDATA". !ELEMENT from (in line 5) defines the from element to be of the type "#PCDATA" and so on.....

16 External DOCTYPE declaration If the DTD is external to your XML source file, it should be wrapped in a DOCTYPE definition with the following syntax: Tove Jani Reminder Don't forget me this weekend! And this is a copy of the file "note.dtd" containing the DTD:

17 XML Schema XML Schema is an XML based alternative to DTD. An XML schema describes the structure of an XML document. The XML Schema language is also referred to as XML Schema Definition (XSD). An XML Schema: –defines elements that can appear in a document –defines attributes that can appear in a document –defines which elements are child elements –defines the order of child elements –defines the number of child elements –defines whether an element is empty or can include text –defines data types for elements and attributes –defines default and fixed values for elements and attributes

18 A Simple XML Schema This is a simple XML Schema file called "note.xsd" that defines the elements of the XML document above ("note.xml"): <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3schools.com" xmlns="http://www.w3schools.com" elementFormDefault="qualified">

19 Viewing XML files Raw XML files can be viewed in Mozilla, Firefox, Opera, Internet Explorer, and in Netscape 6+. However, to make XML documents to display like nice web pages, you will have to add some display information With CSS (Cascading Style Sheets) you can add display information to an XML document. Look at this XML file: Look at this XML file: note.xml note.xml

20 Displaying XML files with CSS Take a look at this XML file: The CD catalogThe CD catalog Then look at this style sheet: The CSS fileThe CSS file Finally, view: The CD catalog formatted with the CSS fileThe CD catalog formatted with the CSS file –XSL (the eXtensible Stylesheet Language) is the preferred style sheet language of XML. –View the XML file, the XSL style sheet, and View the result.View the XML filethe XSL style sheetView the result

21 XSLT XSLT (Extensible Stylesheet Language Tranformation) is a language for transforming XML documents into XHTML documents or to other XML documents. XSLT is the most important part of XSL XSLT transforms an XML document into another XML document XSLT uses XPath to navigate in XML documents

22 XAML PROGRAMMING Here is the hello world program we wrote in class <Window x:Class="wpfHello.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Say Hello Program" Height="350" Width="525" Background="Gold"> Welcome to My first WPF program!

23 Future value interface with WPF <Window x:Class="WpfFutureValue.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Future Value Program in WPF" Height="458" Width="610" Background="Gray" FontWeight="Bold">


Download ppt "Windows Presentation Foundation (WPF) Chapter 16 Dr. Abraham."

Similar presentations


Ads by Google