Sunday, 25 July 2010
Tab Control in Silverlight
Wednesday, 21 July 2010
Add CSS in ASP.Net class file
Sunday, 11 July 2010
Add/Remove value in cookie
Wednesday, 30 June 2010
Change Silverlight Border Background
Here is an example of Border.
CornerRadius – Make border corner rounded.
BorderThickness – Make border side thickness bold or light.
BorderBrush – Change border rounded color.
Margin – To fix position of border.
We can give a button look and feel of a border by changing LinearGradientBrush property of Border.Background. Expression blend is the best way of changing border style. Manually changing GradientStop color and Offset value we can make border attractive. It can be use as container of another pages, here grdMain is used as a container.
Tuesday, 29 June 2010
Expanded TreeViewItem Style in Silverlight TreeView
ItemContainerStyle – is the expand property.
expandedTreeViewItemStyle – is the name of style.
Below is the calling style.
Treeview control of Silverlight
Through this way we can build up a tree. Child item and inner child item binding. There are various properties of TreeView and TreeViewItem. Header property hold header name. We can bind image with text in stackpanel then bind that stackpanel as a Header of TreeView.
mhItem.Selected += new RoutedEventHandler(modelHomeItem_Selected);
If we apply Selected event it will execute when we click on items on run time.
Sunday, 27 June 2010
WCF Service method async call from Silverlight project.
1. Create WCF service client instance.
2. To catch asynchronous call response we have to use delegates. For every method of WCF service there is a completed event and an asynchronous method. So initially we will assign completed event of any WCF methods.
3. Finally we will make call where it is necessary. For every call there is a completed event, no matter what is return type of calling method. To catch completed event we have to follow step two.
Tuesday, 22 June 2010
Silverlight Page Container
During project creation those methods automatically create. Application_Startup method invokes during initiation and Application_Exit invoke during closing of project. Application_Startup method load MainPage instance by default.
Main Page is the container of .xaml pages. Now we can create layout of our project according to our requirements. Every .xaml page create <Grid/> control by default. To display or show silverlight pages we use grid control. It acts like a container for silverlight pages. But at a time it can hold one page. To load new page previous page has to remove.
grdMenue – Is the grid name.
adminLandingLeftMenu – Is the instance of a silverlight page.
First we clear the children of grid(if any exist) then add new page instance to display.
Friday, 11 June 2010
Data Bind in Silverlight DataGrid
To show data in datagrid view, we need to assign a list to the itemsource of datagrid.
dgSalesOfficeLiveAgent.ItemsSource = e.Result;
e.Result – is the list of data.
Above is enough for .cs file. But in .xaml we should configure the datagrid. There are lots of property of datagrid. According to our requirement it is configurable. Most important things are column configuration. Silverlight datagrid is very powerful. A column can be editable. It may contain multiple controls like TextBlock, Image, TextBox etc. We can combine various controls simultaneous. Basic structure of a datagrid –
Saturday, 5 June 2010
File upload from silverlight project to file server
public void ProcessRequest(HttpContext context)
{
}
Context hold full url. So when we send a request to the handler this method automatically invoked. Now we can extract query string from url.
string action = context.Request.QueryString["action"].ToString();
Where action is the query string name.
2. From silverlight project prepare url and stream data (file) to send into the file server. OpenFileDialog is the class through which we can bind file data to Stream like.
openFileDialog.File.OpenRead();
3. Pass url and data stream by calling UploadFile(url, streamData). Below are the methods. This two methods duty are to send data of the respected url (our handler class).
In the handler class two types of operations take place. One is save data and one is retrieve data.
1. To save data, copy it inside ProcessRequest() method.
BuilderLandingPageImageSave – is the query string, checking the exact query string name of action.
Path – is the location where the file is going to save. Here we saved path name in web.confg file. So we are just calling it.
Filename – is the name of file in which name it is going to save. We can pass the file name from silverlight project by binding query string like action. Below is the WriteFileToDisk() method.
2. To retrive data from ProcessRequest() method
BuilderVideoTutorialLoading - is the query string name.
Path - file location.
ReadMediaFile() method is below.
Friday, 4 June 2010
On click make silverlight pop up on top
1. Get the object which you want to make on top.
2. Increase the zindex of that object.
The highest zindex object will show on top.
Canvas.SetZIndex(ObjectName, ++i);
To take the facility of canvas ZIndex we have to take the objects collection as the child of canvas.
Wednesday, 2 June 2010
Silverlight page dragging
In .xaml file paste above line. In .cs file paste following line.
canvas.Children.Add(object);
To make position of object we can define a margin for it.
object.Margin = new Thickness(200, 150, 2, 2);
Tuesday, 1 June 2010
Edit Template of silverlight controls
1. Open project in expression blend.
2. Select control to edit.
3. Open Object & Timeline window. Right click on control -> Edit Template -> Edit a copy -> Give a name(Optional) -> Click ok.
Sunday, 30 May 2010
Configurable WCF Service url in Silverlight project side
WCF service gets url and binding properties from “ServiceReferences.ClientConfig “ file in silverlight project (client side). When WCF service initialize, it gets all property from this file. There is no problem reading data from that file. But when web site get deployment url are change. So manually you have to change url of WCF services from that file. <endpoint/> tag address property hold WCF url address.
To get rid of this hassle, we can configure it to read the url from web.config file. We can do followings things.
Create a class as an example ServiceFactory. All the initialization related things which is take place in “ServiceReferences.ClientConfig” file, have to be ServiceFactory class. See the sample code.
BasicHttpBinding _BasicHttpBinding;
public ServiceFactory()
{
_BasicHttpBinding = new System.ServiceModel.BasicHttpBinding();
_BasicHttpBinding.MaxReceivedMessageSize = 2147483647;
_BasicHttpBinding.MaxBufferSize = 2147483647;
_BasicHttpBinding.OpenTimeout = new TimeSpan(0, 20, 0);
_BasicHttpBinding.CloseTimeout = new TimeSpan(0, 20, 0);
_BasicHttpBinding.ReceiveTimeout = new TimeSpan(0, 20, 0);
}
Now when we need to make the instance of WCF service we can create a method in ServiceFactory class. So we can bind BasicHttpBinding and EndpointAddress class property within WCF service instance. Look at sample method below.
public PCBuilderServiceClient GetPCBuilderServiceClient()
{
_EndpointAddress = new System.ServiceModel.EndpointAddress(ServiceUrlManager.GetValue(ConstantClass.SERVICE_SERVER_URI) + ServiceUrlManager.GetValue(ConstantClass.PC_BUILDER_SERVICE));
_PCBuilderServiceClient = new PCBuilderServiceClient(_BasicHttpBinding, _EndpointAddress);
}
Here PCBuilderServiceClient is the service name. _EndpointAddress object is binding service url. There are two things one is the server url and another is the exact location and name of the WCF service file in server. So both need to cocate to get the exact location of the WCF service. Initially we have kept thos information inside IDictionary object during starting of the web site. Now just fetching the value from IDictionary by key.