Category Archives: Mango
One of the remarkable features is the “ Calendar & ToDos”.
On september 27th, 2011, pocketnow.com published a very detailed post about Mango’s new features.
Here is the video previewing what you can do with the calendar:
“ Tasks are back!! Not only do Exchange tasks now sync with the “To-Do’s” tab with-in the Calendar, but now Windows Live Hotmail To-Do’s sync there as well. Windows Live’s To-Do’s list never used to sync with anything. It seems strange to call them “Todos” since Outlook calls them tasks, but whatever… at least you can see, edit, and manage the things you have to do at work and in your personal life. Most other smartphones still don’t sync Exchange tasks, and it’s great to see this feature back in Windows Phone… and in full force with Windows Live Hotmail.”
However, not everything related to a consumer’s Live profile is available on the phone natively. So Microsoft released a new Windows Live SDK which allows access to Calendars, Contacts, Documents, and more.
In previous posts, we discussed how to use Skydrive in Windows Phone applications.
This time , we will see how to use the calendar.
As mentioned in MSDN, “ The Calendar object contains info about a user’s Hotmail calendar. The Live Connect REST API supports creating, reading, updating, and deleting calendars. Use the wl.calendars scope to read a user’s Calendar objects. Use the wl.calendars_update scope to create Calendar objects for a user. Use the wl.contacts_calendars scope to read a user’s friends’ Calendar objects.”
So before digging deeper in the code and in the case you did not install the necessary tools, here is what you need:
In the next post, we will learn how to read the calendar.
This is part two on how to use Skydrive in your Windows Phone applications. Part one was an introduction to how to sign in into Skydrive.
In this part, let’s try to read the Skydrive’s folders.
I will use the ApplicationBarIconButton to read from my Skydrive then put the result in a very simple list in another page.
So first, let’s create a new Windows Phone page , I’ll call it “ content.xaml”.
I’ll change the Application title to “ Skydrive” and the page title to “ Folders”. I will also add a listbox.
Now we need to fill that listBox.
In the MainPage.xaml, let’s add an ApplicationBarIconButton ( it is already there as a commented code):
When you click on the button , you should be able to get your content from Skydrive if you are signed in and see it on that listbox we put in “content.xaml”
The result is stored in a “ SkydriveContent “ list :
In the Content.xaml.cs , we will tell the listbox to get its items from the ContentList:
That is all you need to be able to read your Skydrive folders in your Windows Phone application.
There is also an interesting and helpful post in Silverlight Show by Samidip Basu about the usage of Skydrive with Windows Phone.
In case you don’t know what is Skydrive, on Wikipedia you will find that “ Windows Live SkyDrive, initially called Windows Live Folders, is a free-of-charge file hosting service that allows users to upload files to a cloud storage and then access them from a Web browser.”
The Live Connect should recognize your application, that’s why you should go to Live Connect App Management site and create a new app.
You will get a Client ID and Client Secret that you will be using later with your application.
Demo : Sign In
Let’s see how it works now:
Create a Windows Phone Application and make sure to add the following references:
You should also add the SignIn Button to your toolbox :
In the main page, the user should sign in :
In the MainPage.xaml, I added a SingInButton control, You should put your own Client ID. I only used wl.signin and wl.basic scopes at this point.
wl.basic : Allows access to a user’s basic info, such as his or her Hotmail contact list.
wl.signin : Allows user’s log in .
The “infoTextBlock “ will indicate either the user is signed in or not. That will be handled in the C# code.
Run the application , hit the sign in button and you should get this screen:
In this first part, we grabbed the tools and SDK needed in order to use Skydrive in our Windows Phone applications.
Then we learnt how to sign in into Skydrive storage without writing any code.
In part two, we will learn how to read/insert files into Skydrive. Stay Tuned
Making apps is good , making apps that work perfectly is better
In order to make sure that your app works fine you may want to test your code .
So let’s take a walk through Mango Unit Testing Framework.
You can grab the new assemblies from here.
Next you should have something to test …right ?
Nothing complicated, we will work with the famous “ Hello Mango” sample.
In Visual Studio : File—> New project –> Silverlight for Windows Phone
Choose Windows Phone application and name it “ Hello Mango” . Since we are working with Mango, don’t forget to choose the Windows Phone 7.1 version
We will change the application title to “ Hello Mango” , the page title to “ Unit Test” and we will add a textblock containing “ Hello Mango” :
Now that you have your sample app ready , run it to make sure that everything is fine and then we will move to the test project.
the test project is also a Windows phone application called “ HelloMangoTest”
We need to convert the windows phone application to a Unit Test project:
Download the assemblies as describe it below , unzip the file and make sure they are unlocked so you can use them on your local machine.
Add the two assemblies to the “ HelloMangoTest” project :
You have also to delete the MainPage.xaml because Silverlight Unit Test Framework has a TestPage.
One more thing to do :
In the App.xaml.cs, add
, you will have this code:
Set the test project as a Startup Project and now you are ready to write the tests.
add a new class and name it “ test” :
In this test we want to make sure that when the MainPage is initialized , there is indeed a textBlock ( we called it “ txt” ) . Here is the code :
When you run the project, you will get this first screen :
And I have no idea what this screen is I need to ask Jeff Wilcox about it.
Surprisingly it’s not working So I did a small search and found out that I shouldn’t delete the MainPage and change the Rootvisual in the App.xaml.cs.
Instead I put this code in my MainPage.xaml.cs in the test project :
If the Boolean is true, the unit test become the content of the Mainpage.
Let’s run again …Wohoo! It’s working not only on the emulator but also on a real device :
The list of Test classes under your project will be shown in first page. You can go into each class to see all test methods by clicking on the name of class.
In our case you will see Test and pass. Click on the method’s name ( pass) and you will get the test information , the result is “ passed”.
That was an introduction of how to use Silverlight Unit Test Framework with Mango
I was working lately on a new app , ToDo list ( i know , nothing innovative here -_- ) but then I dropped the work till Mango is out,for the very good reason that with Mango I can have a local Database to store and manage my application’s structured data ! Clap ! Clap!
One of the new many features coming with the Windows Phone Codenamed Mango is the possibility of having local databases- Microsoft SQL Server Compact edition databases(SQL CE)- for your applications.
The database resides in the application’s isolated storageas a file.
In case you are not familiar with the isolated storage,I highly recommend you to read the ” All about WP7 Isolated Storage” articles on the ” WindowsPhone Geek” website.
In order to store and retrieve data in the local database, your Windows Phone application has to use LINQ to SQL.
” LINQ to SQL provides an object-oriented approach to working with data and comprises an object model and a runtime.The LINQ to SQL object model is made up primarily by the System.Data.Linq.DataContext object, which acts as a proxy for the local database. The LINQ to SQL runtime is responsible for bridging the world of objects (the DataContext object) with the world of data (the local database). This relationship is summarized in the following image.” MSDN
One more thing to explain is the Data Context . Data Context is the object model that represents the database, each object is a set of entities using the ” plain old CLR object ” (POCO) with attributes.
- Building the application
My ToDo application looks like this :
As you can see, my main page is a panorama containing :
* Hot list item : where you can find the tasks to be done soon
* Lists: tasks will be sorted , tasks related to work, family, etc…
The other page is a simple Windows Phone page that allows you to add a new task.
In this post we will be working with this user interface.By now you should know how to create a new Windows Phone 7.1 application and how to add pages, so all I have to do is to show you the XAML code :
Now that the user interface is ready, we will build the Data Context.
First thing to do is to add the reference System.Data.Linq to be able to work with LINQ to SQL.
Then add a new class, I’ll call it task .
Add another class called TaskDataContext that derives from DataContext:
Notice that we have to check if the database exists , if not we need to create it .
In the MainPage.xaml.cs add the following code:
To sum up, in order to use local database, we need to specify the data context then create the database if it doesn’t exist.
In the coming post , we will learn how to query the database. Stay Tuned
Here is an index for all Mango Baby Steps series.
- Digest Mango
- Setting up the environment
- Creating your first application
- Creating an application with local Database
- Windows Phone : From Where To Start?
- Mango Baby Steps: Unit Testing Your App
This index will be updated each time we have a new post. Enjoy !