Thursday, November 25, 2010

Isolated Storage in Windows Phone 7

Hello.. I hope all are enjoying Windows Phone 7 development.. This is 1 more blog on Windows Phone 7. This blog is regarding isolated storage of Windows Phone 7. In this blog I am going to include a brief introduction on isolated storage of Windows Phone 7 and 1 demo along with its screenshots.

Isolated storage is basically local storage of your Windows Phone 7 mobile. Your applications can save its data in this isolated storage. It is compulsory for the user to save their application data in isolated storage. Windows Phone 7 does not allow storing files in any other file system locations.

Let’s see what exactly isolated storage means. “Isolated” means separated from others. So basically, in this storage each application’s data is isolated from each other. Means 1 application can’t see and access another application’s data. But sometimes it may happen that your 1 application may need data of another application. Then the best option is use of Cloud. You can put your data in cloud and access whichever data you want for any application.

It is very important that developer should keep a watch on data storage. It’s important that you should conserve data space. You can do this by deleting temporary data in storage. Also if user creates any data in the application, developer should allow them to delete it later which will help to conserve space. Using cloud as option is another way of conserving data space. Always give user, information about data getting stored in storage through your application so that if storage is getting full, user will get to know it and accordingly user can delete files.



The above figure is taken from msdn site. You can refer msdn site http://msdn.microsoft.com/en-us/library/ff402541%28v=VS.92%29.aspx for this. This figure shows you the actual storage of data. Figure is self-explanatory. Upper is the main Application Data Store Folder. It has two parts local settings and files and folders structure. 1st is Local Settings which updates the changes made by developer to the application directory. 2nd part is Files and Folders. You can access it by using API. Using these APIs developer can create, delete and manipulate files and folders.
Now let’s see demo for isolated storage.

Step 1:-

As we have to develop windows phone application, we need to choose Windows Phone application in Visual Studio. So it will be File -> New -> Project -> Windows Phone Application.



Once you create a new project you will get your project on your screen as shown in below figure.



Step 2:-

In this demo I am going to show you how to write and store data in isolated storage and also how to read data from isolated storage.
For that I am going to use 1 textbox to take input from user, 1 button to save data, 1 textblock to display stored data and again 1 button to retrieve data from isolated storage and display in above textblock. You can see this UI in figure below.



Step 3:-

Code behind..

As we have to use isolated storage, we need to add 2 IO namespaces.
System.IO
System.IO.IsolatedStorage
So at start you add these namespaces by including using statement in your code behind.



Step 4:-



Here we are going to include the steps for writing and reading data from isolated storage.

In the above figure you can see two methods written btnSave_Click and btnShow_Click. btnSave_Click is written for writing and storing data in isolated storage and btnShow_Clickis written for displaying data from isolated storage.
Let’s start with storing data. Here IsolatedStorageFile represents an isolated storage area containing files and folders. So basically using IsolatedStorageFile we can create directories, files etc were we can store our data. Later on we have created a directory called Data in storage. We can create files in this directory and store data in it. After that we going to use StreamWriter to write data in a file. So what we actually doing here is, 1st we creating a new IsolatedStorageFileStream for a file abc.txt in above created folder. Mode of this file is Create as we going to create this file in above created store (isf in our code). This whole argument is been given to StreamWriter. Later on we going to write in this file whatever input we had taken from the user. Thus we are done with writing data in file.

Now let’s see how to retrieve data. Here again we declaring new IsolatedStorageFile same way as above. Here as we have to read data we going to use StreamReader. So similarly, creating a new IsolatedStorageFileStream for a file abc.txt in above created folder. Mode of this file is Open as we going to open this file which was already created above in our store (isf in our code). This whole argument is been given to StreamReader. After this, we reading data from that file and displaying it in textblock. Thus we are done with reading data in file.

Step 5:-

Now let’s run our application by pressing F5. You will get on screen as shown in below figure.



This is going to be the UI which we had designed.

Now let’s enter input in textbox which will be stored in isolated storage.



Once you click Save button your data gets saved in isolated storage and you get a message box that your data is stored.



Now let’s retrieve this stored data. Click on Show button and you will get the stored data in your textblock as shown in below figure.



That’s it!!! We are done with our isolated storage demo. Will be back soon with such more interesting blogs. Till that time, Good bye and enjoy WP7 developing.

Wednesday, November 17, 2010

Visual Studio Crash After Installing Windows Phone 7 SDK

After installing Windows Phone 7 SDK, when you start Visual Studio 2010 and Click on New Project or immediately after starting Visual Studio 2010, Visual Studio crash run following command in Visual Studio Command Prompt by going to Start > All Programs > Visual Studio 2010 > Visual Studio Tools > Visual Studio Command Prompt

devenv.exe /installvstemplates

Cause: if you run devenv.exe /Log C:\output.txt in your txt file you will notice that there are some duplicate entries for the Project Templates. By running above specified command it will reinstall VS Templates, and solve the issue.

Happy Windows Phone 7 Development :)

Monday, November 15, 2010

Submitting Windows Phone 7 Applications to MarketPlace

Hello.. We had seen how to develop an application for Windows Phone 7. We had seen a very basic application Hello World Application. We will see more later. This blog is for those who are ready with their applications or will be ready with their application. In my blog am going to explain the steps how you can submit your application on Marketplace.

So we have to start with creating an account. Once it’s done go to this site http://create.msdn.com/en-US/ . Login onto this site with username and password of the account created. Once you login you will get below image on your screen.



On left hand side you can see written Submit for Windows Phone. As the name suggests, if you want to submit your windows phone application you can click here for further procedure. Basically, this is a 5-step procedure which you have to complete for submitting your application on Marketplace.

1) Upload
2) Description
3) Artwork
4) Pricing
5) Submit

I will explain you these steps in detail once step by step. So back to Home page. When you will click on “Submit for Windows Phone”, you will a form of “upload” on your screen. You need to upload .xap file of your application. Now what is .xap file.

A .xap file is basically a compiled Silverlight application. The file is actually a .zip file that contains all the files necessary for the application. Just rename the .xap file to have a .zip extension and then you can open it up to see its contents. The .xap file contains an application manifest (AppManifest.xaml) file and all the necessary DLL's that are required by the application. This .xap file is placed in \Bin\Release or \Bin\Debug.

This .xap file to upload should not exceed than 400MB. In the form you can see, Application name. Give your application name. In Application Platform select Windows Phone 7. In language select English language. In version select the version which you have used. In Application Package upload your application. Below two are optional things. Once your upload form filling is done, click Next. It will take you to next step, “description”.



Above image shows how your description form will be. It consist complete description of your application. Depending on this form users will decide to buy your application or not as they will get complete description of your application. So I will suggest you to use many keywords so that it’s easy to for users to find your application. Now let’s see details about form. 1st is application title. You can write here according to your application. Similarly you can select category according to your application. Next is the detailed description. This is the main thing which user will go through. So write as much as possible. Next is optional part. Next field is keywords. Write as many keywords as I mentioned above. Legal URL field is optional. Then is Support Email Address. This field is also optional. But I will suggest you to add this email so that if any user has any issues or questions with your application he can mail you those solutions. So that once you solve those issues user will be satisfied completely. So it’s better to add Support Email Address. Required device capabilities field. This includes the requirements for your application.

Once your upload form filling is done, click Next. It will take you to next step, “artwork”.



Above image shows your artwork form. Artwork form includes tiles or images of your application. This will attract user to buy your application. Large mobile app tile and Small mobile app tile includes tiles of your application. Large has size of 173 X 173px and Small has 99 X 99px. Similarly size of Large PC app title is 200 X 200px. For creating this image you can use Paint.Net or Photoshop. Talking about images, you have to adjust your application image dimensions same like mentioned above. Even if it changes a bit, it will fail. Next field is Background art which is optional field. Next is screenshots. You can add screenshots of your application in this field. With these screenshots user will get proper idea about your application. You can add upto 8 screenshots. Its size is 480 X 800px.

Once your upload form filling is done, click Next. It will take you to next step, “pricing”.



Above image shows your pricing form. In this, 1st field is for trial mode. If your application has trial mode, tick this field. Next is worldwide distribution tick it as your application will be up for whole world. Primary offer currency, you can set this according to your convenience. You can set it as USD etc. Application Price is the price of your application. Set it as per your calculation. You can submit 5 free applications per account.

Once your upload form filling is done, click Next. It will take you to next step, “submit”.



This is the last form. There is only 1 option in this form. Automatically publish to Marketplace after passing certification. Tick this. Once you tick this click on button “Submit for certification” below.

So you are done with submitting your application in Marketplace. Once it’s done you can visit your app hub to see the status. Most of the Windows Phone 7 apps are being tested / approved within a few days. Its same as below image.



If your app fails testing, then Microsoft will send you an email detailing the reason for failure.

This is all with this blog. Will be back soon with few more blogs regarding Windows Phone 7!!! Till that time bye and enjoy development for Windows Phone 7.




Wednesday, November 10, 2010

Tuesday, November 9, 2010

Windows Phone 7

Hello all. I am back with my blogs once again. This time I am going to write a blog on a current hot topic. Guessed correct!!! Windows Phone 7.
All are excited with WP7 topic. Not only for use but also for development of WP7 applications. So for what are we waiting? Let’s start building applications..
I will start with a very basic application and as we all know our tradition “Hello World Application”. I will include screenshots for each of my step so that it’s easy for you to understand visually too. So let’s start…

Step 1-

Let’s start from very basic part – creating new project.
Go to File -> New -> Project.



You will get a screen where you will get options. Check on left hand side, select a language C# or VB and select Silverlight for Windows Phone. After selecting it you will get options regarding Windows Phone Applications on right hand side. Select 1st option – Windows Phone Application. Give your application name below. I have given it name WP7HelloWorld.



Step 2-

You will get a screen where you can see two splitted windows. On left side you can see WP7 device and on right side you can see XAML code. You can design on device using tools from toolbox. If you want to make changes in design through code you can do it on right side.



On top of the device its written My Application this is the name of the title which you can change. Just below is written page name. This also you can edit according to your application. In my application I have changed “My Application” to “Hello World Application” and similarly have changed “page name” to “Hello World”.



Step 3-

Next step we going to do is placing controls. I am going to use 1 textbox where we will take input from user (will take their name as input), 1 button on clicking of which will display output and 1 textblock (which is label in windows forms) to display output. In below screenshot you can see the alignment of these 3 controls. You can select these controls from toolbox which you can see on left side. If toolbox is not visible you can view it from View -> Toolbox.




Step 4-


We want to execute application when user clicks on button. So let’s write code on button click event.




Now what exactly we going to do in our application is, we will take name as input from user through textbox and once user clicks on button we will display “Hello ……” in textblock. So we are going to write the code as shown in below screenshot.




Step 5-

In this step I am just increasing the font size of textblock so that output is properly visible to the user.



Step 6-

Now press F5 to run your application and you will get a screen as shown in below screenshot. This is known as emulator. In your Visual Studio you can see 1 dropdown just below menubar which gives you options as Windows Phone 7 Emulator or Windows Phone 7 Device. If you have actually device you can connect it to your machine and run this application directly on your device. If you don’t have a device not to worry we have Emulator. You can run your application on Emulator by choosing Windows Phone 7 Emulator in that dropdown. Now back to your application running on emulator. You can see the UI which you had designed.



Once user clicks on textbox a keyboard will be popped up from below. If your machine has touch screen you can actually do typing by touching screen and get actual feel of device. If you don’t have touch screen to your machine simply click using mouse on the particular characters which you want to insert in textbox.






Once it’s done click on button and you will get your output below. You can see the output in below screenshot.



That’s it!!! Your application is ready!!!
I will be back soon with more bogs on Windows Phone 7. Till that time. Good bye :-)

Saturday, November 6, 2010

Windows Phone 7 Marketplace Open to All

Microsoft opened the marketplace submission for all developers on 5th November, 2010. You can learn more about it here - http://create.msdn.com/en-US/