BrainDump
  Home arrow BrainDump arrow Page 6 - 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 - Basic Data Binding in Silverlight 2.0: explanation


    (Page 6 of 6 )

    Basically, Silverlight applications execute and run on the client side (browser). No code is executed at the web server level. If Silverlight applications were executed at the server level, we'd simply have another ASP.NET!

    As Silverlight applications execute at the browser level, we are left with no way to communicate with databases directly. So, we will not be able to bind to databases directly. The best options for getting the data from databases are through either web services or WCF (Windows Communication Foundation) services.

    Web Services or WCF components serialize objects (data) and throw them to browser. Once the browser receives them, Silverlight can automatically pick them up and bind the same to Silverlight controls. That is the reason we will be working and binding objects to controls for all kinds of Silverlight applications.

    In the previous section, we defined a simple class as follows:


    Public Class Emp


    Private _Empno As String

    Public Property Empno() As String

    Get

    Return _Empno

    End Get

    Set(ByVal value As String)

    _Empno = value

    End Set

    End Property


    Private _Ename As String

    Public Property Ename() As String

    Get

    Return _Ename

    End Get

    Set(ByVal value As String)

    _Ename = value

    End Set

    End Property


    End Class


    The above class simply encapsulates employee number and employee name information. Once the class is defined, we need to instantiate and bind it to Silverlight controls. Currently, to make this article simple, I instantiated the above class with the following statement (along with some sample data):


    Dim objEmp As New Emp With {.Empno = "1001", .Ename = "Jag"}


    The binding in between the instantiated object and text boxes is made possible using the “Datacontext” property of the controls themselves:


    Me.txtEmpno.DataContext = objEmp

    Me.txtEname.DataContext = objEmp


    We are assigning the same object to both text boxes. But the data gets displayed differently in each of the text boxes. The following declarations made it happen:

     <TextBox Height="20" Width="142" Canvas.Left="170" Canvas.Top="52.269" Text="{Binding Empno}" TextWrapping="Wrap" x:Name="txtEmpno"/>

     <TextBox Height="20" x:Name="txtEname" Width="142" Text="{Binding Ename}" TextWrapping="Wrap" Canvas.Left="170" Canvas.Top="91.269"/>


    The most important attribute on which to concentrate is the “Text” property of TextBox. You can observe that the binding specification is provided with the keyword “Binding” together with the property (of Emp object) to which it needs to bind. It is important to make sure that this information is embedded in braces.

    In my upcoming articles, we will see more and more examples of Silverlight 2.0 development. I hope you enjoyed the article and any suggestions, bugs, errors, enhancements etc. are highly appreciated at http://jagchat.spaces.live.com


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · 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 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek