BrainDump
  Home arrow BrainDump arrow Page 4 - Beginning Silverlight 2.0 Development usin...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
BRAINDUMP

Beginning Silverlight 2.0 Development using Visual Studio 2008
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 6
    2008-10-29

    Table of Contents:
  • Beginning Silverlight 2.0 Development using Visual Studio 2008
  • Developing your first Silverlight 2 application
  • Coding your first Silverlight 2 application
  • Explaining the code
  • Basic Data Binding in Silverlight 2.0
  • Basic Data Binding in Silverlight 2.0: explanation

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Beginning Silverlight 2.0 Development using Visual Studio 2008 - Explaining the code


    (Page 4 of 6 )

    Let us try to understand the previously tested project. If you open Page.xaml, you should see a “Canvas” object as follows:


     <Canvas Margin="30,26,31,34">

     </Canvas>


    Canvas is simply a layout control. A layout control acts as a container to hold a few more child controls along with size and positioning. There exist a few more layout controls in Silverlight like Grid, StackPanel etc. I will cover those in my upcoming articles.

    The Button control gets created using the following markup:


     <Button Height="31" Width="113" Canvas.Left="102" Canvas.Top="21" Content="Disp Message" x:Name="btnShow" Click="btnShow_Click"/>


    The name of the button is defined by using the “x:Name” attribute. Its positioning is currently defined with respect to its container (Canvas). It is currently associated with a click event handler named “btnShow_Click.”

    The Textbox control gets created using the following markup:


    <TextBox Height="25" Width="168" Canvas.Left="71" Canvas.Top="82" Text="" TextWrapping="Wrap" Background="#FFFFFFFF" x:Name="txtFirst"/>


    This is also very similar to the previous Button control except that it is defined with its own background color and name. As we currently don’t need to handle any event with respect to this control, we simply don’t mention any of its events.

    When the button is hit, it executes the following code:


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

    Me.txtFirst.Text = "Hello world"

    End Sub


    The above code is quite clear. It simply assigns the message “Hello world” to the text box named “txtFirst.”

    You can also dynamically modify the properties of a control dynamically as shown below:


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


    Me.txtFirst.Background = New SolidColorBrush(Colors.Blue)

    Me.txtFirst.Foreground = New SolidColorBrush(Colors.Yellow)

    Me.txtFirst.Text = "Hello world"


    End Sub


    Once you execute the above, you should have the following output (Fig 07):

    More BrainDump Articles
    More By Jagadish Chaterjee


       · Hai,This is my first article in the "Siverlight 2.0 development with Visual...
       · nice small article for introduction.. hope to see more database interaction in...
     

    BRAINDUMP ARTICLES

    - Introduction to Office Live Workspace
    - Using MS Excel for One-way Analysis of Varia...
    - Comparing Data Sets Using Statistical Analys...
    - Import Blogger Posts into WordPress Using Wi...
    - Download WordPress from an FTP Server and Ru...
    - Install and Run WordPress in XAMPP Local Host
    - What Windows 7 Brings to the Table
    - Virtualization and Sandbox Detection
    - Advanced Firebug Techniques in Windows XP Ho...
    - Editing CSS with Firebug in Windows XP Home
    - Using Firebug in Windows XP Home
    - Migrating to Exchange Server 2007
    - Using System Restore on a Non-Bootable PC
    - Finding Logged on Users and More Scripting S...
    - Developing Macro Commands in MS Excel





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek