Advertisement

Getting started with Silverlight: Part 1 - The tools and Hello World

This is a first part in a series of getting started posts for Silverlight developers. 

In our series in getting started, we’ll eventually build out an application that searches Twitter for monitoring keywords and automatically refreshes at a specified interval.  Before we start getting too deep, let’s make sure you have the tools necessary to get started and understand the fundamentals of the developer experience for Silverlight.

The Tools

Of course, with any development all you need is a text editor and a compiler, but you’d be crazy these days not to use world-class tools.  That being said, what I will propose here are a set of tools to make your complete development experience with Silverlight simpler and faster.  Not all are required (again, you just need notepad and a compiler if you are hard core :-)).  Not all are free either.  But I highly recommend them not just because I work at Microsoft, but I truly believe they are the best tools for the job.

Visual Studio 2008

You’ll want to make sure you have Visual Studio 2008 in your first bag of tricks.  You will need Service Pack 1 for VS installed to get the Silverlight tools, so make sure you have that.  Any version of Visual Studio 2008 SP1 will work with the tools.  If you do not have a copy of Visual Studio 2008, you can use one of the free express versions, Visual Web Developer Express 2008 to do Silverlight development.  If you plan on doing database development as well, you can get SQL Server 2008 Express as well for no cost.

Silverlight Tools for Visual Studio

The Silverlight Tools for Visual Studio is an additional download that installs the SDK, developer runtime (for debugging) and a set of tools for Visual Studio (project templates, build targets, etc.).  This one package installed on top of VS will get you everything you need for your VS development environment for Silverlight.

For both of these, Visual Studio and Silverlight Tools, you can download them separately.  If you already have VS, just download and install the Silverlight Tools and you will be up and running.  If you don’t have VS, consider using the Web Platform Installer which will install Visual Studio, SQL Server Express and the Silverlight Tools for you – without you having to hunt around for the installers.  You can get the Web Platform Installer here:

Web Platform Installer with Silverlight Tools

If you already have Visual Studio installed, you can still install the Silverlight Tools using WebPI or you can download them directly here.

Expression Blend

Expression Blend is an interactive developer tool.  It is a visual designer for XAML, the underlying presentation technology for Silverlight and Windows Presentation Foundation (WPF) applications.  It has a great design surface and allows for easy manipulation of layout, animations, styling and templating.  I believe this to be an essential tool in XAML development.  This tool, however, is not available at zero cost.  If you have an MSDN Subscription it is included in some levels.  It can also be purchased as a part of Expression Studio.  You can download an evaluation copy of Expression Blend 3 here to get started.  We will use Blend for layout in the next step.

Silverlight Toolkit

The Silverlight Toolkit is a set of additional controls that are available outside of the core control set.  These include charting controls, date/time controls, accordions and much more.  Best of all, the source code for these controls (as well as all the core controls) are included for you to learn from and extend!

The toolkit is available for download from CodePlex and we will be using some controls from it in this series.

There are other control suites and tools you can use like .NET RIA Services which we will discuss in step 3, but I think the above are my recommended minimum tools you should have for Silverlight development.  Install them all before proceeding in this tutorial in step 2.

Understanding the development environment

Once you install Visual Studio and the Silverlight Tools you will notice a new grouping in the VS New Project dialog box:

New Project Dialog Box

You will see some new templates under the category Silverlight which include at least Silverlight Application, Silverlight Class Library and Silverlight Navigation Application.  Some others you may see depending on additional tools you may have installed.

For this step, choose the Silverlight Navigation Application template and give it a name for the application (I’m calling mine TwitterSearchMonitor).

The next window you will see will ask you if you would like to create a web project:

New Silverlight Application Dialog Box

If this is a new project, I highly recommend choosing to create a web project for you.  By doing this you will have a web context to run the application for you.  This is helpful in avoiding issues around accessing web services from the local file system.  Running your application under HTTP from the start will help you avoid some of the most common mistakes in debugging web service access.  You can choose the ASP.NET Web Application Project, ASP.NET Web Site or ASP.NET MVC Project if you have that installed.  If you aren’t sure, just use the defaults.

The Project Structure

Once your app is created you will see something similar like this:

Silverlight project structure

This shows your web application (which will host the Silverlight application) with pre-created test pages for the Silverlight application and the Silverlight application itself.  Let’s focus first on the Silverlight application project.

There are some key files you should be aware of here that we’ll explore in this series:

  • App.xaml – this is an application-wide resource file.  If you put resources in here (we’ll explore in styling) or global events upon startup, they will happen here.  This file is also the entry point to your application and tells the Silverlight plugin what to do next.
  • MainPage.xaml – this is a page that is a part of the template you chose.  It doesn’t have to be called MainPage, but that is what the project template uses by default.  This represents the starting user interface for your application.  Don’t be confused by details just yet.
  • Assets/Views folders – these contain assets (files, images, styles, etc.) and other UI views for your application.

The XAML files are the files that make up the UI of your application.  They are just XML files with the XAML markup language.  We will be altering these in later steps.

When you build the solution (go ahead and do that) you’ll notice in the web application’s ClientBin folder a new file with a XAP extension will show up.  This is your compiled Silverlight application.  It’s actually an archive (aka ZIP) file with a different extension file name.  If you rename it to .ZIP and open it using an archive tool you can see the contents.

The XAP file is what is served to your browser.  This is the file that is hosted on the web server and gets delivered to the end user.  The XAP is hosted within a standard HTML page that hosts the Silverlight application using the <object> tag instantiation. 

NOTE: Silverlight is a client technology and can be hosted on any web server.  It can be any type of web server that is capable of delivering the XAP file along with the correct content MIME type from the server (application/x-silverlight-app).  As long as it does that, we don’t care what type of web server it is delivering the XAP file.

Test pages for ASP.NET and HTML are created for you with the standard template.  Since both of them are the same essentially, I usually delete one of them for simplicity.

Adding UI to the XAML pages

The template we chose is a navigation application template, meaning it has some navigation features built into it.  This is a fairly new feature to Silverlight and enables you to have a “master page” kind of view in your application.  If you look in the Views folder you will see About.xaml, ErrorWindow.xaml and Home.xaml.  For now let’s focus on Home.xaml since that is the first view that is loaded.  Open that file up by double-clicking it and you’ll see the XAML load in Visual Studio.

In this page you’ll see some XAML code that defines the view in a Grid that uses some other layout controls like a StackPanel and TextBlocks (we’ll go into StackPanel in the next step 2).  These are all part of the core control set that Silverlight provides.  A TextBlock enables you to present text to the user.  If you run the application now (hit F5 to run in debug mode – go ahead and choose to modify the web.config to enable debugging) you should see something like this:

Running Silverlight application

Notice the text in the running application matches the text in the TextBlock of the XAML.  Also notice the link style buttons in the upper right.  These represent our navigation points which go to our separate views.  Let’s add some more XAML and see how to write code.

In the Home.xaml view, after the second TextBlock, add a Button using this XAML:

   1: <Button Content="Click me" x:Name="MyButton" FontSize="18" Width="150" Height="45" />

This will display a button on the view just underneath the “Home page content” text area.  Notice the x:Name attribute?  This is the unique identifier for this element and helps us reference it in code.  Think of this as the ID attribute of the control.  Now let’s make it do something when clicked.  There are two ways we can add events to the Button (or other elements) with simplicity.  In the XAML for Button itself we can add a Click attribute and you will see VS Intellisense automatically ask us if we want to generate a new event handler:

We can also wire up the event handler in code directly and keep it out of our XAML using this code in the Home.xaml.cs page:

   1: public Home()
   2: {
   3:     InitializeComponent();
   4:     MyButton.Click += new RoutedEventHandler(MyButton_Click);
   5: }

Either way will work.  For simplicity for now you can use whatever you like…I will use the XAML method for now.  Now in the function MyButton_Click we can write managed code in the function to manipulate our user interface or other functions.  Let’s finish our Hello World sample by changing the HeaderText TextBlock (HeaderText is the x:Name value so we can reference it easily in code) to “Hello World” output.  To do that we’ll write this function code:

   1: void MyButton_Click(object sender, RoutedEventArgs e)
   2: {
   3:     HeaderText.Text = "Hello World!";
   4: }

After making these changes and running the application again (F5) we will see our button and when clicked it will change the text like below:

finished product animation

Next Steps

We’ve created our first Hello World Silverlight application.  We’ve got more to do to complete our Twitter search application.  Let’s move to step 2 to change some of our layout of our views for our application.  For more information on getting started check out the other resources here:

We won’t provide the code download here because this was just to get us started.  Future steps we’ll include a link to the finished project always.  Hope this helps…let’s move on to part 2!


This work is licensed under a Creative Commons Attribution By license.

  1. 10/6/2009 9:44 PM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    I am very new to development so this may seem basic. I started the application as directed. It is in read-only mode. How do I change this so I can add code? Thanks
  2. 10/7/2009 7:48 AM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Karen -- I assume when you mean "started" you did the F5 to actually run the application? You can't edit code while you are in debug mode. Simply close the browser (or stop debugging) and you can edit the code.
  3. 10/7/2009 10:18 AM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Finally made my first steps in Silverlight. KISS all over the place. This first part gives a simple and solid structure to experiment with. Great!
  4. Gravatar
    10/8/2009 8:19 AM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Excelent! Will continue on the series.
    []s,
    GB
  5. 10/14/2009 10:28 PM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    This helps alot,I did video on navigation but had trouble following code in video,was to fast for me. then download code but not run apparently due to web config. So started here and this format works for me.Thanks Tim,you do have an audience.
  6. 10/17/2009 3:10 PM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Hi Tim, just trying out your tutorials, but i do not have the Views or Assets folders you appear to - I have downloaded everything as mentioned, any idea what i've done?

    Cheers
  7. 10/18/2009 5:00 PM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Hi there Tim. I like your writing style. This is very interesting stuff. I want to eventually create OLAP presentation for Analysis Services. Do you know if RIA will simplify hooking up to ADOMD.NET?
  8. 10/18/2009 5:41 PM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Mike - make sure you choose the Silverlight Navigation Application template.

    Bobby T - I am not sure how well that would work, but only because I've not tried :-)
  9. Gravatar
    10/19/2009 9:03 AM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Hi Tim - After I create the project and click OK, I get an error which says HRRESULT: STG_E_FILENOTFOUND. I am not sure why I am getting this. I am not able to create the project itself.
    I dont know if this is because I have VS 2010 beta!
  10. 10/19/2009 9:10 AM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    ARD -- Are you using VS2010 beta 1 here? It isn't supported for SL3 development.
  11. Gravatar
    10/19/2009 9:12 AM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Hey Tim - No I am not using VS 2010. I am using VS 2008, however its installed on my machine.
  12. 10/19/2009 9:17 AM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    ARD - Seems like an odd error then, but could be related. I don't have that environment to confirm. Perhaps re-installing the Silverlight 3 tools might help.
  13. Gravatar
    10/19/2009 6:43 PM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Hey Tim - Finally after re-installing VS2008 everything works :) .... As you said all the problem was caused by SL3 Tools specifically KB967143...it was not getting uninstalled....
  14. 10/20/2009 9:59 AM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    I have created a new Silverlight Application, but I don't have any Views or Assets folders, any idea why? Did I miss out a step?
  15. 10/20/2009 10:04 AM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Sorry about that question. I saw your answer to the same question in a post above
  16. 10/22/2009 10:08 AM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World

    hi there tim
    new to silverlight getting main reason was air-america for their show then slip into my main desire cartooning or graphic novel creating. Found right off the bat. flickr4writer downloading this as I jot down this comment.
    Can you lead me into the art of graphic novels with silverlight has anyone tried or done this?
    kindly~ jimoer`i`ke`
  17. 10/22/2009 7:54 PM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    I am running Windows Vista. I have VS2008 and have installed Silverlight Tools for Visual Studio. I can create a simple "Hello world" type Silverlight app. (C# in this case) but:
    have to re-size the XAML surface in order to see design surface.
    design surface has message:
    Load Cancelled
    Loading of the visual designer was cancelled
    (hyperlink to "Resume loading the designer"
    when I click "resume reloading the designer", the design surface now appears but the "switch panes" is disabled, cannot drag and drop controls onto the design surface, etc.

    Any light would beat the darkness

    thanks.
  18. 10/22/2009 10:28 PM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Gary -- Sounds like you are using Silverlight 2? There is no editable design surface in VS2008 for Silverlight 3 development -- you cannot drag/drop controls. This is enabled in VS2010 (which is currently in beta 2)
  19. 10/23/2009 9:52 AM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Tim --
    Ahh! I am, indeed, attempting to use SilverLight 3 with VS2008. I wish to continue to use VS2008. Can I install Silverlight 2 alongside my existing Silverlight 3? ("Can I" in the sense of 1) is it possible and 2) is it likely to work well? )

    thanks.
  20. 10/23/2009 9:56 AM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Gary - Yes it is possible, but not entirely intuitive or streamlined. Read this: timheuer.com/.../...s-with-visual-studio-2008.aspx
  21. 10/24/2009 11:48 AM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    hi,Tim.
    I am new.
    when I tried to debug,I got a Error"The tag 'Expander' does not exist in XML namespace 'clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls'.
    what's the matter?

    thanks.
  22. 10/24/2009 12:01 PM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    wzy77cn - where are you using the Expander in this tutorial? I'm not using it. Regardless it is in one of the other Toolkit assemblies (layout I think).
  23. 10/24/2009 9:10 PM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Hi,Tim
    thanks for you reply.

    I created a new Silverlight Navigation Application project and kept all defalut settings,and then click DEBUG button,and then I got this error "The tag 'Expander' dose not exist" .The error is on File ErrWindow.xaml,line 21 and the error line code is '<controls:Expander Grid.Row="2" Header="Details" Margin="0, 10, 0, 0" >'.

    thanks.
  24. 10/24/2009 10:07 PM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    wzy77cn - ah! i was looking in the wrong place. I forgot that the nav template uses toolkit controls in the ErrorWindow. Expander is a toolkit control. Make sure you have the Silverlight Toolkit (http://silverlight.codeplex.com) installed and this should resolve the reference. If you look at the project references I'm sure you'll see the warning next to a missing one.
  25. Gravatar
    11/2/2009 6:07 PM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World


    Hi Tim,

    Thanks for this great intro to Silverlight 3.0.
    I just started the TwitterSearchMonitor project, following your instructions ( except one ;-) , I used a VB project) and when I run it, I get the error message below.
    I use VS 2008 Team System and Windows 7 Ultimate.
    Thanks
    gm

    Line: 56
    Error: Unhandled Error in Silverlight Application
    Code: 2104
    Category: InitializeError
    Message: Could not download the Silverlight application. Check web server settings
  26. Gravatar
    11/2/2009 6:16 PM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Tim,
    I think I found the issue.
    In the generated page "ErrorWindow.xaml.vb", in line 14 I changed the line

    from:
    ErrorTextBox.Text = "Page not found: \"" + uri.ToString() + " \ ""
    To:
    ErrorTextBox.Text = "Page not found: ' + uri.ToString() + ' "

    It seems the escaping of the quotes is not correct in the generated page. This may be something for the SilverLight team to correct.

    Thanks
    gm
  27. 11/5/2009 7:44 AM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    hi,
    didn't get views & assets directory.
    how i can bring then in a application.
    I see Shawn msg and sorry msg also but
    didn't get idea.
    please help
  28. 11/5/2009 8:27 AM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Alex - be sure you create the project with the Silverlight Navigation Application template as noted above.
  29. 11/9/2009 2:22 AM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Hi,
    The content in this tutorial was very helpful.
  30. 11/13/2009 8:17 AM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    its crap
  31. 12/1/2009 10:37 AM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    this cool:
  32. 12/1/2009 2:45 PM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Hi Tim,

    Thank you for the great tutorial. I am new at VS and Silverlight. When doing the tutorial, my Home.xaml screen doesn't look the same as yours. On mine the code text is black, and the intellisense isn't working. Any light you could shed on this issue? Thanks. I'm on Windows XP, VS 2008, Silverlight 3 Tools.
  33. 12/1/2009 3:04 PM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Heather -- did you successfully see the "Silverlight Aplication Template" though and created a project using that?
  34. 12/2/2009 7:34 AM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    I have installed everitying but the only template I can see is Silverlight Unit Test Application. where I can download the Navigator?
  35. 12/2/2009 10:03 AM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Simone -- make sure you install the Silverlight Tools for Visual Studio: http://go.microsoft.com/fwlink/?LinkID=143571 (as noted above)
  36. 12/2/2009 8:33 PM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Hi Tim,

    Thank you for the tutorials. I ran into an issue while trying to install Silverlight Toolkit 3.
    I currently have VS 2008 standard edition installed. When I try to install the
    toolkit it says my Visual Studio 2008 Remote Debugger is not compatible. What do I have to do to bypass this issue?

    Thanks,
  37. 12/3/2009 2:47 PM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Kareem -- send me a screenshot of this error you are seeing -- timheuer at microsoft dot com.
  38. Gravatar
    12/14/2009 9:25 AM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Hey Tim,

    When I try to run the application I receive the Install Silverlight image instead of the application. I have Silverlight 3.0 installed. What might be causing this problem?
  39. 12/16/2009 9:44 AM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Hi Tim,

    I currently have the Evaluation Build of Windows 7 installed, VS2008 with SP1, plus the silverlight tools, expression blend etc... I'm following the 1st steps of this which seem very straight forward, but when I execute the "Home.xaml" page as instructed, it gives me the following error:

    Unhandled Error in Silverlight Application
    Code: 2104
    Category: InitializeError
    Message: Could not download the Silverlight application. Check web server settings

    I've already downloaded the Silverlight app and installed it - Could you point me in the right direction?

    It seems this is a problem associated usually with IIS which I know nothing of, as well as to do with MIME types... Please help :)
  40. 12/16/2009 9:55 AM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Matt -- make sure you build the entire solution -- not just run the Silverlight application. The build task copies the XAP file to your web solution.
  41. 12/21/2009 10:22 AM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    good starting
  42. 12/29/2009 7:44 AM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Well started.
  43. 12/29/2009 9:56 PM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    hi tim,
    i did all the steps you mentioned .. i added a button but its not visible wen i run the application
  44. 1/6/2010 11:56 AM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Hi Tim,
    I'm an old hat programmer fumbling my way through learning Silverlight/C# and VS2010 beta. So far this is great! The only thing with VS2010 and VS2008 is that you have to pay attention to what is going on in your page and read ahead a bit.
    Anyway, thank you!
  45. 1/12/2010 2:39 PM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Hi Tim,
    Is it possible to have a single silver light page with in normal web application? I have a web site developed in VS 2008 and now the client wants the search results page to be in silver light.
    Any idea?
    Thanks,
    Syed
  46. 1/12/2010 4:19 PM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    I created a Silverlight application with default settings. I made no change to it. When I try to run it using CTRL+F5, it gave me teh following error. What settinsg do I need to change to run the application succesfully.
    ==========================================================================

    Unhandled Error in Silverlight Application
    Code: 2104
    Category: InitializeError
    Message: Could not download the Silverlight application. Check web server settings
  47. 1/12/2010 5:57 PM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Sanwar -- make sure you compile the SOLUTION and not just the application.
  48. 1/12/2010 5:58 PM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Syed -- absolutely -- take a look at any of the many Silverlight sample applications and you will see that some of them integrate with the web app itself.
  49. 1/15/2010 4:37 PM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Hi Tim, after created application, it's only show me one application in solution explorer, Do I have to add TwitterSearchMonitor.Web nauually? Thanks
  50. 1/15/2010 5:00 PM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    multinet - you needed to make sure you chose the option to create a new web application for you.
  51. Gravatar
    1/17/2010 9:50 PM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Hi Tim,
    I'm very new to this stage of web development. I'm thinking of going to collage to learn in greater depth. I've use FP and then went to EW I have created a few sites of my own (woodthings.biz & trimplus.biz) with these programs. Over the years I have learned as I use the programs, no schooling.
    Anyways I am trying to follow your VWD 2008 tutorial and got stuck on where exactly I am supposed to add the line of code to change the word "Home" to "Hello World". The "void" function. Am I right to call "viod" a function?

    Thanks

    I really appreciate you web developers/designers taking the time to help us newbies out.
  52. 1/18/2010 6:36 AM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Hi Tim,

    Great tutorial indeed, thanks :)

    I have Silverlight 3.0 installed on VS 2008. Since, there is no editable design surface in VS2008 for Silverlight 3 development, is there any easy way to design UI? For instance, changing the style of Button, without having to run the application every time to check the output.

    Is MS Expression Blend a good option?

    Thanks,
    Syed
  53. 1/19/2010 5:10 PM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    hi tim

    thnx for your effort.
    i have a stupid question

    where do i put this code for the click button
    void MyButton_Click(object sender, RoutedEventArgs e)
    {
    HeaderText.Text = "Hello World!";
    }

    thnx
  54. 1/20/2010 4:41 AM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    I liked it, i think silverlight is going to be much more fun...
  55. Gravatar
    1/21/2010 1:18 PM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Hi again Tim,

    Like I said in my previous post I I've been learning as I use my software. I just wanted to let you know I figured it out. I created my project in VB instead of C#. Than I just played with it and figured out what and where to do the changes.

    Thanks
    Leo
  56. 1/26/2010 10:04 AM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Justin:

    If you created your project in VB instead of C# and decided to use the Event Handler for the Click attribute, just go to your home.xaml file and right-click on Click="MyButton_Click" for a menu to pop up. From there, select "Navigate to Event Handler" to be taken to the Home.xaml.vb file. You'll automatically be placed in Private Sub MyButton_Click. Most of the code has already been input for you, and should look like this (in VB):


    Private Sub MyButton_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)

    End Sub


    From here, just type in HeaderText.Text = "Hello World!" between the Private Sub string and End Sub, so the completed code looks like this:


    Private Sub MyButton_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
    HeaderText.Text = "Hello World!"
    End Sub


    Save it, and when you hit F5 again to compile, you should get a working web page with a working "Click Me" button.

    Keep in mind that this is for VB. I hope it helps!
  57. 2/3/2010 12:52 PM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    I have no Assets + Views folder, should I create them manually?
  58. 2/6/2010 5:34 PM | # re: Getting started with Silverlight: Part 1 - The tools and Hello World
    Hi there.

    I've installed everything as mentioned, however when I open Visual Basic 2008 Express, my New Project dialog box is a choice of 6 options, with no additional windows as the screenshot shows.

    I'm very new to all of this, so I'm a little stuck for what to do, as I've re-read the instructions many times.

    Any help would be much appreciated.

 
Please add 8 and 2 and type the answer here:
First time here? You are looking at the most recent posts. You may also want to check out older archives. Please leave a comment, ask a question and consider subscribing to the latest posts via RSS or email. Thank you for visiting! (hide this)