Pages

Saturday, April 30, 2011

How to Customize On-Screen Keyboard Layout in Windows Phone 7 application ?

While you want to enter some text in your Windows Phone 7 application, the first thing that you will notice is your very own on – screen keyboard. As Windows Phone 7 mobile have a very large screen area, most of the phones does not have an analog keyboard associated with it. Hence your application should provide provision to handle keyboard events directly using on-screen keyboards. There are few flexibilities available to you while you define your input scope, in this post I will demonstrate them with an example.

What is InputScope?

InputScope is a special functionality to the developers to customize how the layout of the keyboard appear to the user while entering data into that particular textbox. Hence you can easily customize the On-Screen Keyboard for your input so that one can easily feed in data fast and easy. For instance, say if you want to take phone number as input,you need only digits and some special characters to be available, on the other hand, email needed alphanumeric characters with @ as symbol. Silverlight introduces the new option to let you specify the InputScope for a particular input. Lets look into the code below :

Thursday, April 28, 2011

Async support for Silverlight and WP7

Async support in C# language brings the new life to the modern application development to bring forth the same technique of writing your code and bring asynchrony easily. The main focus of async ctp is to ornament the language in such a way so that the developer could seamlessly create applications that brings asynchrony yet not dealing with its complexity. Hence using the new technique, asynchrony could easily achieved in a program without refactoring the whole program with lots of callbacks and method calls. I have already talked about it in a separate article. If you don’t know, please visit “Async CTP 5.0”.


Async CTP is released again recently and announced in MIX 11. Just after it is released, the first thing that everyone looks for is what is new in the release. As a matter of fact, I did jumped back to see them but eventually found out that there is nothing new in this build in terms of new features is concerned but the release focuses on fixes of performance adding debugging capabilities etc. I will definitely look back to them later in another post, but in this post I am going to talk about another important thing that featured with this release. As opposed to the previous release, the current release now supports Silverlight and Windows Phone 7 environments. This seems to be interesting.

What is Asynchrony?

The word asynchrony means something that is running without blocking other operations running in parallel. If you have created a background Thread to process some data, you are actually doing asynchronous job in background as your foreground operation does not get hampered. In vNext C# introduces Asynchrony using TPL. The two new keywords “async” and “await” could be used to make one sequential method asynchronous. Hence the new way of developing asynchronous program replaces the traditional approach where we needed to refactor the code totally to gain asynchrony in our application. Basically, this is done using the StateMachine to store the entire method into a form of states, and each states are delegated into batch of statements. The Task.ContinueWith is used in the system to ensure that the method body gets executed sequentially. Yes, it’s a compiler trick. If you want to know more about it, please read through my entire article on “Async CTP”.

Wednesday, April 27, 2011

Application Bar for your Windows Phone 7

If you are working with Windows Phone 7, the first thing that you should have noticed is the very own Application bar. Application Bar is present in most of the applications that you use in your Windows Phone 7. This is basically a standard Toolbar with a menu associated with it which allows you to enumerate the commonly used commands in a standard location. While creating your application, Microsoft strongly recommends you to add an application bar, to ensure the user have common behaviour for every application. You can think Application bar similar to TaskBar of windows.

Components of Application Bar

An application Bar is made up with two components:

1. ApplicationBar Buttons
2. ApplicationBar Menu


The applicationbar buttons are always visible for an application which is used to list only the items that needed to be frequently used while dealing with the application. Lets say you create a Text processing application, you can list the File->Open and File-Save commands as ApplicationBarButtons.

ApplicationBarMenu pops up when the user clicks on either the blank space of the application bar or the special button with 3 dots. The Application Menu is used to list the items that are not used often but needed sometimes in the context.

Sunday, April 24, 2011

Working with Isolated Storage for Windows Phone 7

During the last few days, Microsoft is getting more and more inclined towards improving the user experience in more than  a number of technologies. Silverlight being one of the major forerunner on this moving good in Web by providing Rich Internet Applications for end users. But not only for Web, Silverlight is a language being used for Windows Phone 7 as well, which gives the silverlight developers a chance to move over to Windows Phone easily. Being a WPF developer, I am totally freaked out on watching stuffs related to Windows Phone as richness in UI always attracts me. I have learned a few about Windows Phone 7 as well, but never got a chance to speak about it. Lets speak a little about the use of Isolated Storage (if you have already read my article here),  in Windows Phone 7 in this article.

Isolated Storage

We say Files and Folders are the building blocks for any application. We need to store data in our Phones to persist data when the application is not running. In case of Windows Phone 7 microsoft provides a secure way to store data into Isolated Store. Isolated Storage, as the name suggests is a special virtualized file system that every application can access for standard IO operations yet the file is unavailable to any other application. Hence the files stored by one application is isolated from another.

Each application has a root of the store of this Virtualized File system. You can use the store to create folders and files. The main advantage of the Isolated store is independence between the actual file system and the application. Hence it gives a strong decoupling between the actual physical architecture of the system and the application. To understand, lets see the image below  :



Here we have three applications running on Windows Phone, and each accesses its own root in the Virtualized file system for data storage. The application API cannot access the physical file system, but interacts with the Virtualized File system for its I/O operations. Thus if our physical file system changes, our stores will still be available and our application will run independently.

Sunday, April 17, 2011

Closures in CSharp

Closures are an interesting feature for a language. I have heard a lot of questions around how we can declare closures in C# and hence I thought to start a blog on it. Over the internet, there are lots of examples on closures available which are taking help of functional languages like F#, yes it is very important in perspective of these languages as those are easy to declare and also inherently supported yet other languages like C# or VB.NET can also take help of these feature. Lets take a look how C# can take help of closures in this post.

What is a Closure? 

Closures may be defined as a set of behaviour or instructions that are encapsulated as an object such that it could be sent to other object yet can hold the context of the caller.  In other words, a closures are special object that are encapsulated into an object but can hold the context of the caller.

In C# we define closures using delegates. In C# 3.0 we have language support to easily declare a delegate in a program. This widely increases the use of delegates in the program using lamda expressions. Lets put the closures in terms of some examples.

Thursday, April 14, 2011

Silverlight 5 Beta - Lets deal with its features

In MIX 2011, we can see our very own silverlight new version called Silverlight 5 beta is released. Yes, if you are looking for it, its time to download the beta and try them out. The major goal of Silverlight 5 is to move the silverlight development more towards the WPF and hence releasing some of the benefits that you already enjoy being a WPF developer is now available to silverlight. In this post lets talk about the features that were introduced with Silverlight one by one.

To install Silverlight 5

To try the features, you first need to download the Beta. Lets follow the steps to install silverlight in your machine.

  1. You first need to download Visual Studio 2010 (SP 1) if you didn't have done that already. 
  2. After you install Visual studio update you need Silverlight tools for Visual Studio
  3. Optionally you can also try Silverlight help tools to get started.
Now after you are done with this, lets talk about few basic features introduced in Silverlight 5.

Silverlight 5 Features 

You should notice that there are few major benefits that are not present yet with Silverlight 5 beta, to name a few :
  • Our old requirement to support 64 Bit is not present
  • You still cannot launch external applications (using PInvoke) with elevated trust level
  • DataContextChanged is still not present.
  • Vector Printing

Tuesday, April 5, 2011

Azure Camp Kolkata on 10th April 2011



  • Entry is Free on First come - First Server Basis.
  • Total Number of seats : 30
  • Attendees need to bring their own laptops with internet connection for Hands - On Labs and access to Windows Azure. Check Laptop Specification.
  • Attendees need to register for free trial for Azure Portal which needs International Credit Card for sign up. Details for this offer is available at http://www.microsoft.com/windowsazure/free-trial/
  • Please visit campaign website to know contest details. http://www.wholeadstomorrow.com/


Schedule

City                    : Kolkata
Date                   : 10th April 2010
Venue                :  Microsoft Corporation (I) Pvt. Ltd. L & T Chambers 4th Floor,
                             16 Camac Street,
                             Kolkata - 700017                    Map

See More about  Venues and Timings


SPEAKERS


Abhishek Sur

Microsoft MVP - Client APP DEV 2011 Codeproject
MVP, Associate | DotNetFunda MVP | Kolkata .NET Star | Writer | Technology Evangelist
| Geek | Speaker
www.abhisheksur.com


Abhijit Jana

.NET Consultant at Microsoft | Former Microsoft
MVP - ASP.NET | CodeProject MVP, Mentor, Insiders| Technology Evangelist | Author
| Speaker | Geek | Husband
www.abhijitjana.net



`For any Query : contact@abhisheksur.com

Be there !!!

Monday, April 4, 2011

Internals of LINQ

If you remember my post on Annonymous Types, I have already stated that there is no concept of annonymous types in MSIL. Every generated type will be mapped to a concrete type produced by C# compiler during the runtime. In this post, I am going to cover few basics of LINQ, and how it is been maintained in IL. If you are very new to Linq, it is recommended to learn the basic usage of it first. You can read my article on Linq Basics, to know more about it.

LINQ means Language Integrated Query is one of the major step forward to .NET framework to support queries to work on objects. LINQ allows you to write custom query statements on .NET objects or more specifically any IEnumerables to filter or fetch data from it.

In this post, I am not covering the basics as I have already discussed it in a separate article. Lets start with internals.