IT tutorials
 
Mobile
 

Windows Phone 8 : Creating a New Project (part 2) - XAML

12/12/2012 6:26:27 PM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

XAML

In Silverlight, development is really split between the design and the code. The design is accomplished using a markup language called XAML (rhymes with camel). XAML (or eXtensible Application Markup Language) is an XML-based language for representing the look and feel of your applications. Since XAML is XML-based, the design consists of a hierarchy of elements that describe the design. At its most basic level, XAML can be used to represent the objects that describe the look and feel of an application. These objects are represented by XML elements, like so:


<Rectangle />

<!-- or -->


<TextBox />

You can modify these XML elements by setting attributes to change the objects:

<Rectangle Fill="Blue" />

<!-- or -->


<TextBox Text="Hello World" />

Containers in XAML use XML nesting to imply ownership (a parent-child relationship):

<Grid>
  <Rectangle Fill="Blue" />
  <TextBox Text="Hello World" />
</Grid>

Using this simple XML-based syntax you can create complex, compelling designs for your phone applications. With this knowledge in hand, we can make subtle changes to the XAML supplied to us from the template. We could modify the XAML directly, but instead we will start by using the Visual Studio designer for the phone. In the main editor pane of Visual Studio the MainPage.xaml file is split between the designer and the text editor for the XAML. The left pane of the MainPage.xaml file is not just a preview but a fully usable editor. For example, if you click on the area containing the words “page name” on the design surface, it will select that element in the XAML, as shown in Figure 8.

Figure 8. Using the Visual Studio XAML design surface

Image

Once you have that element selected in the designer, the properties for the element are shown in the Properties window (which shows up below the Solution Explorer). If the window is not visible, you can enable it in the View menu by selecting “Properties window” or by pressing the F4 key. This window is shown in Figure 9.

Figure 9. Location of the Properties window

Image

The Properties window consists of a number of small parts containing a variety of information, as shown in Figure 10.

Figure 10. Contents of the Properties window

Image

The section near the top (#1 in Figure 10) shows the type of object you have selected (in this example, a TextBlock) and the name of the object, if any (here, “PageTitle”). This should help you ensure that you have selected the right object to edit its properties. The next section down (#2) contains a Search bar where you can search for properties by name, as well as buttons for sorting and grouping the properties. The third section (#3) is a list of the properties that you can edit.


From the Properties window you can change the properties of the selected item. For example, to change the text that is in the TextBlock, you can simply type in a new value for the Text property. If you enter “hello world” in the Text property and press Return, the designer will change to display the new value. Changing this property actually changes the XAML in the MainPage.xaml file. The design surface is simply reacting to the change in the XAML. If you look at the XAML the change has been affected there as well, as shown in Figure 11.

Figure 11. The changed property

Image

You can edit the XAML directly as well if you prefer. If you click on the TextBlock above the PageTitle (the one labeled “ApplicationTitle”), you can edit the Text attribute directly. Try changing it to “MY FIRST WINDOWS PHONE APP” to see how it affects the designer and the Properties window:

...
<TextBlock x:Name="ApplicationTitle"
           Text="MY FIRST WINDOWS PHONE APP"
           Style="{StaticResource PhoneTextNormalStyle}" />
...

Depending on their comfort level, some developers will find it easier to use the Properties window while others will be more at ease editing the XAML directly. There is no wrong way to do this.

Although the Visual Studio XAML designer can create interesting designs, the real powerhouse tool for designers and developers is Blend. Let’s use it to edit our design into something useful for our users.

 
Others
 
- Windows Phone 8 : Creating a New Project (part 1) - Visual Studio
- Developing BlackBerry Tablet Applications : Permissions and Configuration Settings
- Developing BlackBerry Tablet Applications : Permissions
- Introducing Windows Phone 8 : The Marketplace
- Introducing Windows Phone 8 : Application Lifecycle, Driving Your Development with Services, Live Tiles
- Introducing Windows Phone 8 : Input Patterns
- Iphone Application : Using Address Book, Email, and Maps (part 4) - Using the Message UI
- Iphone Application : Using Address Book, Email, and Maps (part 3) - Using a Map Object
- Iphone Application : Using Address Book, Email, and Maps (part 2) - Accessing the Address Book
- Iphone Application : Using Address Book, Email, and Maps (part 1)
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us