Monday 15 October 2012

Silver light basic information


Silverlight is a web application framework that runs on the client and delivers Rich Internet Applications
(RIA) capability.
Silverlight is not only an appealing canvas for displaying rich and interactive Web and media
content to end users. It is also a powerful yet lightweight platform for developing portable, crossplatform,
networked applications that integrate data and services from many sources.
Furthermore, Silverlight enables you to build user interfaces that will significantly enhance the
typical end user experience compared with traditional Web applications.
App.xaml & App.xaml.cs: This class is the entry point for the application as a whole. The class handles
application startup and has several events for handling application wide events such as startup, exit and
unhandled exceptions.
public App()
{
this.Startup += this.Application_Startup;
this.Exit += this.Application_Exit;
this.UnhandledException += this.Application_UnhandledException;
InitializeComponent();
}
private void Application_Startup(object sender, StartupEventArgs e)
{
this.RootVisual = new MainPage();
}.

1. "App" represents the application class. This class handles instantiation and other application level
tasks.
2. "MainPage" has xaml to describe the user interface for your application and code-behind to define the
logic.
3. After the Silverlight application is compiled, the "xap" is placed in the host web application \ClientBin
folder.
4. Standard ASP.NET or HTML test pages are automatically added to the host web application. These
pages contain "<object>" tags that reference the Silverlight plugin. The two pages are substantially the
same. Looking at the "*.html" file we can see that it contains boilerplate Javascript code for handling
Silverlight errors. In the HTML portion of the file below the Javascript, there is an "<object>" element. The
object element represents the Silverlight plugin. Notice that it has a series of parameter tags that tell it
where the "xap" file can be found and what Javascript should be run if there's an error.
"minRuntimeVersion" and "autoUpgrade" are configured to automatically update the plugin if it is out of date.. .

Silverlight Devlopment Tools
Both Visual Studio and Expression Blend can be used to build Silverlight applications. In fact, you can work
in both environments for the same project and pass the project back in forth. Both environments sense
when changes have been made outside their environments and update their interfaces accordingly. Both
environments have shortcuts to invoke each other.
Silverlight SDK
The SDK includes the necessary Silverlight assemblies, documentation, Visual Studio templates and
examples. This download is required for developing Silverlight applications. The install currently includes the
following DLL's:
System.ComponentModel.DataAnnotations.dll
System.Data.Services.Client.dll
System.Json.dll
System.Runtime.Serialization.Json.dll
System.ServiceModel.PollingDuplex.dll
System.ServiceModel.Syndication.dll
System.Windows.Controls.Data.dll
System.Windows.Controls.Data.Input.dll
System.Windows.Controls.dll
System.Windows.Controls.Input.dll
System.Windows.Controls.Navigation.dll
System.Windows.Data.dll
System.Windows.VisualStudio.Design.dll
System.Xml.Linq.dll
System.Xml.Serialization.dll
System.Xml.Utils.dll

Mainpage.xml
Your typical starting point for a XAML file is the either the App.xaml or MainPage.xaml. In App.xaml you
can define resources for the entire application. We will discuss resources a little later but for now take a
look at MainPage.xaml. The page starts out looking like the example below.
Adding and Theming RadControls
Once installed to the Toolbox, RadControls can be dragged into the XAML just as you would drag a
standard Silverlight control.
DataBinding
Path: The name of the source property to get the data from. The example below omits the "Path" attribute
in favor of the shorter syntax where the property following "Binding" is the Path, i.e. "Title".
Source: The standard CLR object that contains the data. This object is assigned to the
FrameworkElement DataContext.

Mode: The data's direction of travel. This can be OneTime where the data is set one time and is not
updated after that, OneWay where the data flows one way from the CLR object to the Silverlight element
and TwoWay where the source object updates the target element and the target element can also update
the source object.
<UserControl.Resources>
<local:Category x:Key="Category" Title="Fiction"
Description="No one is better than you,other than yourself.just believe and never be afraid." />
</UserControl.Resources>
<Grid x:Name="LayoutRoot">
<TextBox x:Name="tbTitle"
Text="{Binding Title, Source={StaticResource Category}, Mode=OneTime}"
HorizontalAlignment="Left" VerticalAlignment="Top" MinWidth="100"
></TextBox>
</Grid>

No comments: