Published: 12 Nov 2008
By: Eyal Albert

In this "How to" we are going to learn how to create your own Visual WebGui Silverlight theme using our default theme.

Overview

You should be familiar by now with “What is Visual WebGui” and “What is Visual WebGui over Silverlight”. It is recommended that you read “How to create a Visual WebGui Silverlight application” and other articles in our “Get Started with Silverlight” section.

Visual WebGui (VWG) SDK supplies you with a default theme to your application. This theme holds the default display specification to all the Visual WebGui controls. The VWG Silverlight installation adds a new project type “Visual WebGui Silverlight Theme”. This project allows you to take the default theme and design it according to your needs.

Let's Start

Let's open one of the previous applications that we created in one of our previous “How to”. I’ve opened “How to embed HTML inside a Visual WebGui Silverlight application”.

Now, add a new project to our solution. Select a project type Visual WebGui Silverlight theme

Figure 1: Selecting the project type

Selecting the project type

Our new theme project should look like this. The Generic.xaml file holds the XAML styles of all the VWG Silverlight controls.

Figure 2: Structure of the Project

Structure of the Project

Let’s look at one of them. This is the Window Background Style. This style defines the style of a window in a Silverlight application.

This is how it looks like.

Figure 3: Output of the example

Output of the example

Now, let’s change the gradient color of the rectangle to a different color. 

Next we will set the build order of our application. Right click on the solution and select properties. Open project dependencies and set HtmlBox to depend on MyTheme project.

Figure 4: Setting the build order

Setting the build order

Now, let’s build our application. If this is the first time you build your application you will see the packager application. Make sure that the new theme is included in the main package.

After the build has completed open the web.config; the theme section should look like this

Set the selected theme to MyTheme Selected="MyTheme". Save and close the web.config file.

Let’s rerun the application. Itwill look like this:

Figure 5: Output of the Example

Output of the Example

This will be our default window theme in our application. You can reuse this theme project in any VWG application by just adding a reference to the .dll in the package manager and setting the theme to the default theme.

Next we will edit another style but use Expression blend this time. So let’s open the Expression Blend and create a new Silverlight2 project.

Figure 6: Creating a new Silverlight Project in Blend

Creating a new 

Silverlight Project in Blend

Figure 7: Creating a new Silverlight Project in Blend

Creating a new 

Silverlight Project in Blend

Add a user control to the project.

Figure 8: Adding a User Control to the Project

Adding a User Control 

to the Project

Add a button to the user control.

Figure 9: Adding a Button to the User Control

Adding a Button to the 

User Control

Right click on the button and select “Edit Control Parts (Templates)” –> “Edit a Copy”

Figure 10: Editing a Template

Editing a Template

Click ok to create the ButtonStyle resource.

Figure 11: Creating the ButtonStyle resource

Creating the ButtonStyle 

resource

Let’s get back to our VWG theme project and locate the “ButtonStyle” style and copy it. Now, go back to the Expression Blend and replace the button style with our style.

Click on the button and select “Edit control Parts (Template) “ –> “Edit Template” option.

Figure 12: Editing the Template

Editing the Template

Select the “MouseOver” event.

Figure 13: Selecting the MouseOver event

Selecting the MouseOver 

event

Open the Timeline panel and set the time to 0.25 sec.

Figure 14: Setting the Timeline

Setting the Timeline

Now, we’ll rotate the button to the point that it is 90 degrees.

Figure 15: Rotating the Button

Rotating the Button

On the 0.5 sec rotate another 90 degrees.

Figure 16: Rotating another 90 degrees

Rotating another 90 degrees

And once again at 0.75 sec.

Figure 17: Rotating again at 0.75 sec.

Rotating again at 0.75 sec.

Last time make it complete a 360 degrees turn.

Figure 18: Making a 360 degrees turn.

Making a 360 degrees turn.

Now, open the XAML and copy the button style back to the generic.xaml file in our theme project.

On the MouseOver event of the ButtonStyle set the RepeatBehavior property to forever so our new effect will last forever as long as the mouse is over the button.

Let’s add a button to the form.

Figure 19: Adding a Button to the form

Adding a Button to the form

And run the application.

Figure 20: Our application up and running

Our application up and 

running

Summary

We have seen how to use Visual WebGui Silverlight theme project to customize and to design your application. We used Expression blend to edit the default XAML and created an animation to the button MouseOver event.

The original article can be found here.

<<  Previous Article Continue reading and see our next or previous articles Next Article >>

About Eyal Albert

Sorry, no bio is available

This author has published 6 articles on DotNetSlackers. View other articles or the complete profile here.

Other articles in this category


Displaying Notification Messages in a Silverlight Dashboard Application
In this article we will see how we could display a notification message and further a list of notifi...
Develop a Flexible 2.5D Scene Editor Targeting Silverlight RPG Games - Part 1
Starting from this article, I'm going to introduce to you an excellent 2.5D RPG games scene editor -...
Develop a Flexible 2.5D Scene Editor Targeting Silverlight RPG Games - Part 2
In this article, I'm going to introduce to you how to construct such a 2.5D RPG game scene editor th...
Widget Refresh Timer in MVVM in Silverlight
In this article we'll see how to refresh and disable widgets using the Model View View-Model pattern...
Air Space Issue in Web Browser Control in Silverlight
Air Space issue is a common issue in Web Browser control in Silverlight and WPF. To explain the issu...

You might also be interested in the following related blog posts


RadElement Lifecycle – a WinForms TPF Story read more
Video: CodeRush Metric Shader Plugin read more
Gauge for SQL Server Reporting Services by Nevron read more
Working on Silverlight .NET RIA Services Part 2 read more
Mixing Silverlight and MS ASP.NET AJAX 3.5 in the same web application. read more
An out-of-browser install pattern for Silverlight read more
Improved type safety when dealing with generic types, generic methods and reflection read more
Who Activates, Displays, and Closes Screens? read more
Silverlight Twitter Client with authentication read more
ASP.NET Membership Tip: Requiring New Users To Change Their Password When Logging On For The First Time read more
Top
 
 
 

Please login to rate or to leave a comment.

Free Agile Project Management Tool from Telerik
TeamPulse Community Edition helps your team effectively capture requirements, manage project plans, assign and track work, and most importantly, be continually connected with each other.