Adding Custom Visual Styles

You can create custom visual styles for each of Studio for iPhone's fourteen controls. In this topic, we will illustrate this feature by adding a custom visual style to the C1ViewPort control; however, these steps can be applied to any control with slight modifications, which will be noted throughout this topic. This topic assumes that you have created an AJAX-enabled ASP.NET project that contains a ScriptManager control (see Creating an AJAX-Enabled ASP.NET Project) and a C1ViewPort control.

For more information on custom visual styles, see Custom Visual Styles.

In Design View

Complete the following steps:

1.   In order to add a custom visual style to your project, you must first create new folders and add your custom CSS style sheet to the project by completing the following steps:

a.   In the Solution Explorer window, right-click your project and select New Folder from the tasks menu. Name the new folder "VisualStyles".

b.   Add a new folder under the VisualStyles folder and name it "CustomStyle".

c.    Add another folder,"C1ViewPort", under the CustomStyle folder that you made in the last step. The folder hierarchy should match the following image:

 

 

Note: This folder must be named after the control. If you were applying a custom style to the launch pad, for example, the name of this folder would be C1LaunchPad.

 

d.   Right-click the C1ViewPort folder and select Add Existing Item to add your custom .css file to the project folder. Name the .css file "styles.css

The styles.css file is added to your project.

 

 

2.   In Solution Explorer, double-click styles.css to open the style sheet and then replace the existing CSS body style with the following CSS styles:

CSS Styles

Note: If you want to apply a style to another control, you can modify the CSS styles from one of that control's visual styles and add it to this style sheet instead. You can find visual styles for each control in the C:\\Program Files\ComponentOne Studio for iPhone\VisualStyles.

 

3.   Set the following C1ViewPort properties:

      Set the UseEmbeddedVisualStyles property to False

      Set the VisualStylePath property to "~/VisualStyles".

      Set the VisualStyle property to CustomStyle (external).

      The C1ViewPort control adopts your custom style.

In Source View

Complete the following steps:

1.   Complete steps 1 and 2 under "Adding Custom Styles in Design View".

2.   Enter Source view and enter VisualStyle="CustomStyle", VisualStylePath="~/VisualStyles", and UseEmbeddedVisualStyles="False" into the <cc1:C1ViewPort> tag. Your HTML will resemble the following:

 

 <cc1:C1ViewPort ID="C1ViewPort1" runat="server" UseEmbeddedVisualStyles="False"

        VisualStyle="CustomStyle" VisualStylePath="~/VisualStyles">

3.   Open the project in  a Studio for iPhone-compatible browser and observe that the C1ViewPort1 has adopted your custom visual style.

In Code

Complete the following steps:

1.   Complete steps 1 and 2 under "Adding Custom Styles in Design View".

2.   Double-click the Web project to place a Page_Load event in the code editor. 

3.   Set the UseEmbeddedVisualStyles property to False by adding the following code to the Page_Load event:

      Visual Basic

      C#

4.   Change the VisualStylePath property:

      Visual Basic

      C#

5.   Select the custom visual style:

      Visual Basic

      C#

6.   Open the project in a Studio for iPhone-compatible browser and observe that the C1ViewPort control has adopted your custom visual style.

 This topic illustrates the following:

The result of this topic will resemble the following image:

 


Send us comments about this topic.
Copyright © GrapeCity, inc. All rights reserved.