Tag Archives: visual studio 2008

Hyperlink or Linklabel in Silverlight

Silverlight 3 does not have a control similar to link label. This post tells you how you can add a hyperlink or linklabel in Silverlight 3.

Expression Blend:

1. Create a Silverlight project.

2. Add a Text Block object. Change the text to suit your requirement, let’s say My Website.

3. Under Properties->Brush tab, change the color to R=0, G=0, B=204.

4. Under Properties->Text tab, click on the Underline button. This will add underline to the text.

5. Under Properties->Common Properties, change the Cursor to Hand. (Choose from the drop down list)

6. Under Events tab, double click on MouseLeftButtonUp to add a event handler. In the code-behind, you can open the desired website.

Modifying XAML:

1. Create a Silverlight project

2. In MainPage.xaml, add the following lines

<TextBlock Text="My Website" TextWrapping="Wrap" TextDecorations="Underline" Foreground="#FF0000CC" Cursor="Hand" MouseLeftButtonUp="TextBlock_MouseLeftButtonUp"/>

In the event handler, add the code to open your website.

Advertisements
Tagged , , , , , ,

Visual Studio: Restore Missing Templates

Symptom: You cannot add a new project or an item in Visual Stuio IDE.

Problem: Open the Event Viewer (Control Panel->Administrative Tools->Event Viewer) and see if the suggestion says “Run devenv.exe /installvstemplates”. If this is the case, then the problem is the template files are missing.

Solution:

1. Close all instances of Microsoft Visual Studio.

2. There are two folders under IDE folder (C:\Program Files\Microsoft Visual Studio xx\Common7\IDE), namely ProjectsTemplateCache and ItemsTemplateCache. Delete these two folders. Yes, I said, delete. If you are hesitant, don’t worry, it will go to the recycle bin from where you can retrieve them.

3. After deleting the folders, open the command prompt and run this command: Devenv /InstallVSTemplates .

4. Done. The template files should be restored and you should be able to add new projects and items.

I found myself in this situation out of nowhere. I was innocently coding and debugging and when I tried adding a control to my project, I suddenly see this error message. Thank God, the solution was this simple. Imagine spending another 4 hours on reinstalling Visual Studio. I wonder why I got into this situation, in the first place. Any idea?

Tagged , ,