XAML Basic

Introduction

What is XAML?

XAML is the primary format for declaring a Silverlight UI and elements in that UI. Typically at least one XAML file in your project represents a "page" metaphor in your application for the initially displayed

XAML is an XML-based markup language. XAML is a declarative language used in Silverlight to create UI, such as controls, shapes, text, and other content presented on the screen. XAML files are XML files that generally have the .xaml extension.
 
XAML is XML-based and therefore must follow XML rules, which includes being well formed.
XAML, like all XML-based languages, is case-sensitive.

XAML generally follows XML syntax rules, just as any other XML-based markup language does. Each XAML element has a name and one or more attributes. Attributes correspond directly to object properties, and the name of the XAML element exactly matches the name of a CLR class definition.

There are tools like Visual Studio or Expression Blend to create the UI and  they also generate XAML for the UI.

Every element in a XAML document maps to an instance of a .NET class. The name of the element matches the name of the class exactly. For example, the element <Button> instructs WPF to create a Button object.

As with any XML document, you can nest one element inside another. As you’ll see, XAML gives every class the flexibility to decide how it handles this situation.

You can set the properties of each class through attributes. However, in some situations an attribute isn’t powerful enough to handle the job. In these cases, you’ll use nested tags with a special syntax.

The basic syntax for declaring XAML elements and attributes is:
<ElementName AttributeName="Value" AttributeName="Value" ... />

How does this work?

The XAML parser needs to know the .NET namespace where this class is located.
The xmlns attribute is a specialized attribute in the world of XML that’s reserved for declaring namespaces

There are two ways to declare a namespace:
1.   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2.   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

In first, The first declaration maps the Silverlight core XAML namespace as the default:
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

In Second, The namespace is mapped to the prefix x. That means you can apply it by placing the namespace prefix before the element name (as in <x:ElementName>).

For instance, in order to join any code-behind to a XAML file through a partial class, you must name that class as the x:Class attribute in the root element of the relevant XAML file.

Every event in XAML can be assigned to a codebehind handler, which is implemented in a supported .NET language. For example, it’s a common task to do something when a Button is clicked. So let declare a button in XAML code:


<Button onClick="ButtonClick"
 Name="Bt1"
 Width="50"
 Content="Click Me" />

In code behind we will declare the handler which execute when button is clicked.


void ButtonClick(object sender, RoutedEventArgs eventArgs)
{
MyButton.Width = 100;
MyButton.Content = "Thank you!";
}

All XAML attributes can be manipulated within code because they are simply XML representations of actual CLR class attributes.

You can also line the code in XAML file by specifying the <x:code> element. All inline code must be enclosed in the <CDATA[...]]> tag to ensure that the parser does not try to interpret the code.


<x:Code>
<![CDATA
void ButtonClick(object sender, RoutedEventArgs eventArgs)
{
MyButton.Width = 100;
MyButton.Content = "Thank you!";
}]]>
</x:Code>

In next part we will see what are Elements in XAML.

20. January 2011 06:53 by Administrator | Comments (0) | Permalink

Getting Start with Silverlight

Introduction

What is Silverlight?

Silverlight is  a cross-browser, cross-platform implementation of the .NET Framework for building media experiences and rich interactive applications (RIA) for the web, the desktop, and the mobile devices. You can also create Silverlight applications that run outside of the browser on your desktop. 

Silverlight combines the best of web application development with the power of .NET. Silverlight applications that can be desktop applications, full-page in-browser RIAs, or components interacting with HTML and JavaScript on existing web pages.

Why to use Silverligt?

These are  the feature of silverlight which shows why should we need to use silverlight?

  1. Silverlight lets you create immersive graphics, animation, media, and other rich client features, extending browser-based UI beyond what is available with HTML alone.
  2. Tools Support. You can use development tools, such as Visual Studio and Expression Blend, to quickly create Silverlight applications. 
  3. Extensions to JavaScript. Silverlight provides extensions to the universal browser scripting language that provide control over the browser UI, including the ability to work with WPF elements.
  4. Access to the .NET Framework programming model.
  5. LINQ. Silverlight includes language-integrated query (LINQ), which enables you to program data access using intuitive native syntax and strongly typed objects in  .NET Framework languages.
  6. Cross-browser, cross-platform support. Silverlight runs the same on all popular browsers (and on popular platforms).
  7. 7.Networking support. Silverlight includes support for HTTP over TCP. You can connect to WCF, SOAP, or ASP.NET AJAX services and receive XML, JSON, or RSS data.  

What required in Browser?

To run a Silverlight web application, users require a small plug-in in their browser. The plug-in is free. If users do not already have the plug-in, they are automatically prompted to install it. The download and installation take seconds and require no interaction from the user except permission to install. You can install the plug-in from here.

Getting started and Setting up your environment

For creating a silverlight application you need to download below mention software. If you are new to Silverlight 4 development, the quickest way to get started is to install Visual Studio 2010 or Visual Web Developer 2010 Express, and then install the Silverlight 4 Tools for Visual Studio 2010.
Download and install the VS 2010  
Download and install the Silverlight 4 Tool for VS 2010 

What need to learn before creating silverlight application?

We need to learn the basic of these term before working on silverlight. I will explain each of these term in my next article.

  1. XAML
  2. MVVM Design pattern
  3. RIA Service
  4. WEB service (optional)

 

7. January 2011 06:04 by Administrator | Comments (0) | Permalink

Simple URL ReWriting

URL rewriting is the process of intercepting an incoming Web request and redirecting the request to a different resource. When performing URL rewriting, typically the URL being requested is checked and, based on its value, the request is redirected to a different URL.  URL rewriting can be one of the best and quickest ways to improve the usability and search friendliness of your site. 
Read More.. 

31. December 2010 05:51 by Administrator | Comments (0) | Permalink

IT Project Management

What is a Project?

A project is the means of converting a vision, a dream or a need to reality. Such a need could have arisen due to business, personal or social reason.

Read More..

15. November 2010 07:52 by Administrator | Comments (0) | Permalink

Add Google adsense search box

We generally face problem to add "Google Adsense for search" in master page. The master page by default contains a form tag and your google search box code also contains a form tag. The error is thrown because a single page cannot contain more than one form tag.

Read more.. 

1. August 2010 09:46 by Administrator | Comments (0) | Permalink

Single Instance of Application in window form

While creating window application we generally come across a problem of running multiple instance of same application. For this problem we have two type of solution.
a. C# Trick
b. Using Mutex

Read more..

6. March 2009 09:03 by Administrator | Comments (0) | Permalink

Extend session using javascript in c#

Here I have implement the java script approach with asp.net to find session expire and show the confirm message to user before 1 minutes.

read more...

 

6. March 2009 08:59 by Administrator | Comments (0) | Permalink

Div and Flash Movie

Introduction
Some time I have to work on flash which should be inside a div so that I can hide some portion of flash and some time I have to use flash in div so that I can position the flash in the center of page.

read more....

15. February 2009 12:23 by Administrator | Comments (1) | Permalink

Customize Checkbox Control

Well, I was working on a project in which i need a customize check box. I want to use image for check box. I google on net and found no solution for customize checkbox for asp.net checkbox control. The idea is i want to write a code which make a asp.net checkbox control customize able without writing any code in checkbox control.

Read more..

6. February 2009 09:35 by Administrator | Comments (0) | Permalink

Rating Control

Well, I was working on a project in which i required a rating control. This rating control is developed using web control class. In which we have 4 properties. By using this property we can use the rating control.

read more... 

 

6. February 2009 08:39 by Administrator | Comments (18) | Permalink