Applying default styles quickly to your Windows Phone 8 application in Visual Studio

Applying default styles quickly to your Windows Phone 8 application in Visual Studio

Default templates for Windows Phone application comes with few basic set of resource elements that defines the controls color, size, background etc.  To examine it more closely; you may noticed the  MainPage.Xaml created with the default template has three page level styles defined as static resources.

Default Resources for Windows Phone 8 Application

In a quick thoughts, you may try to explore your solution to find out where are those styles defined. But, you can not find these resources in your solution. These resources are the global Windows Phone resources and can be accessible to any of the Windows Phone Application.

The easiest way to locate and look around the definition of the resources is to select the “Go To Definition (F12)” against each resources.

Resource Go To Definition

Must Read :Go To Definition in XAML Code Editor – Visual Studio 2013

So for any control, if you need to apply the predefined styles, you have to apply the style by mentioning the resource name.  With the help of Visual Studio, you can use this feature very  easily  by just apply the styles in the designer .

Step 1. Select the element and right click to display the context menu .

Edit Style for Controls

Step 2. Select “Edit Style” -> “Apply Resource” and then select the predefined styles from the list of resources  as shown in the below image.

Select Resources

You will find the style is applied and an element has been added with the control

Applied Style

Abhijit Jana

Abhijit runs the Daily .NET Tips. He started this site with a vision to have a single knowledge base of .NET tips and tricks and share post that can quickly help any developers . He is a Former Microsoft ASP.NET MVP, CodeProject MVP, Mentor, Speaker, Author, Technology Evangelist and presently working as a .NET Consultant. He blogs at http://abhijitjana.net , you can follow him @AbhijitJana . He is the author of book Kinect for Windows SDK Programming Guide.