A new home

I’ve made the move to WordPress!

You should be automatically redirected in 5 seconds. Please visit World Wide Code on Wordpress

Hope to see you there!

Friday, November 18, 2011

HTML5 on IE8


Many of you must have read that older browsers like IE7 and IE8 do not support HTML5.
Well, there is a workaround for this purpose. Add the following code to your HTML5 website to get it working on theses ”outdated” browsers.(Sorry WinXP users you have to use IE8 :( )
<!--[if lt IE 9]>
<script type="text/javascript" src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<style type="text/css">header,nav,section,article,aside,footer,hgroup { display: block;}</style>
<![endif]-->
Related Links

Laying out HTML with CSS Grids


Grid Layout contains features targeted at web application authors. The Grid can be used to achieve many different layouts. It excels at dividing up space for major regions of an application, or defining the relationship in terms of size, position, and layer between parts of a control built from HTML primitives.
Like tables, the Grid enables an author to align elements into columns and rows, but unlike tables, the Grid doesn’t have content structure, and thus enables a wide variety of layouts not possible with tables. For example, the children of the Grid can position themselves with Grid Lines such that they overlap and layer similar to positioned elements

Understanding MVVM in 5 Minutes


The Model-View-ViewModel (MVVM) pattern provides a flexible way to build Silverlight applications that promotes code re-use, simplifies maintenance and supports testing. The pattern consists of three different components including the Model (entities and code on the server), the View (the Silverlight screens) and the ViewModel (the glue between the Model and the View).
The essential aspects of MVVM are: The Model, the View and the ViewModel.
MVVM is defined by the separation of the Model from the View from the ViewModel. This separation pattern clearly delineates the responsibilities of each of the essential aspects of MVVM.

Asynchronous Programming in C# and Visual Basic


When your user interface is unresponsive or your server doesn’t scale, chances are you need your code to be more asynchronous. With today’s .NET Framework and language features, though, that is easier said than done.
The Microsoft Visual Studio Async CTP proposes a new language feature in C# and VB, and a new framework pattern to go with it, that will make asynchronous programming similar to – and about as straightforward as –synchronous programming.

Building Metro Style Apps with C++ and JavaScript



Raman Sharma: Building Metro Style Apps with C++ and JavaScript
Creating a Metro style app with Javascript doesn’t mean Javascript is the only language you can use. There are several reasons to leverage compiled code as well, which will be covered in this session. Learn how your Metro style app with HTML5 can directly access native code.
Raman Sharma will show you how to access your C++ Windows Runtime components from JavaScript. After this talk, you’ll understand how to combine native and script code in order to build the most compelling Metro style apps.
Download
Related Links

HTML5 Video Support in IE9 Mobile

HTML5 video is one of the most visible and easily adoptable features of the HTML5 standard. With the Mango release, Microsoft is adding support for the HTML5 <video> tag to the browser in a way that is standards-compliant, hardware-accelerated, and optimized for a mobile viewing experience. YouTube is already taking advantage of this support as they rolled out a new mobile site tailored for the Mango browser.

  • Same Implementation on Mobile and Desktop
  • Optimized Playback Experience 
  • Flash / HTML5 Video Coexistence

Saturday, October 8, 2011

How to: Use a Background Worker


In Silverlight, there is a BackgroundWorker class that provides a mechanism to perform time consuming tasks on a background thread.
The BackgroundWorker also allows you to report progress back to the UI thread and also cancel the on going operation.
Here are some steps about how to use the background worker.

Azure Storage Explorer

Windows Azure gives you four core storage services that are secure, scalable and easy to access that remain persistent and durable storage in the cloud.

Azure Storage Explorer


Azure Storage Explorer is a useful GUI tool for inspecting and altering the data in your Windows Azure Storage storage projects including the logs of your cloud-hosted applications.
All 3 types of cloud storage can be viewed and edited: blobs, queues, and tables.

Web Aunthentication Error in Metro Apps


Metro apps in Windows 8 can make use of Web Authentication using the WinRT API.
You may encounter errors while using the AuthenticateAsync method from the WebAuthenticationBroker inside your Metro App.
The Error returned is usually similar, for example
Error returned by WebAuth broker. Error Number: – 2146697211 Error Message: Unknown runtime error.
You must be connected to the internet.

Windows 8: Web Authentication in Metro Apps


You may have used  OAuth 2.0 protocol for authentication and authorization in your Desktop or web based apps. Now, you would like to build a Metro app for Windows 8 which requires web authentication.
For this purpose, there exists a Web Authentication WinRT API do perform the required task.
The web authentication can be performed using C# as well as JavaScript. 

The Past, Present and Future of Parallelizing .NET Applications


In the MSDN magazine article, Stephen Toub explains the use of parallel tasks like PLINQ in .Net 4.0. I recommend reading this article to get some insights on parallel operations whether you use them or not in your applications.
With the Parallel class, you can parallelize it simply as follows:
  1. Parallel.For(0, N, i => {
  2.   … // Process i here
  3. });
Here, the developer is still responsible for ensuring each iteration of the loop is in fact independent, but beyond that, the Parallel.For construct handles all aspects of this loop’s parallelization.

Stephen Toub is a principal architect on the Parallel Computing Platform team at Microsoft.

Tuesday, August 30, 2011

SketchFlow for Windows Phone 7


Many of you might have used SketchFlow for your various applications.
Now that there’s a Sketchflow template for Windows Phone applications, you can (and should) prototype any projects. The time you spend prototyping and working out any issues and finding ambiguities in requirements will be well worth it.


Read more of this post

Isolated Storage in Silverlight


Storing data in the Isolated storage can be useful, however you need to take appropriate precautions.
  • Wrap all calls to isolated storage within try/catch blocks to be resilient to potential IsolatedStorageExceptions, which can be thrown if isolated storage is disabled or if the store has been deleted.
  • If your Silverlight application needs to store a lot of data in isolated storage, consider hosting it on its own site so that it won’t affect other applications on the site and other applications won’t affect it.
  • If you have a group of Silverlight applications that need to share data on the client, host them on the same site.
  • Keep isolated storage paths as small as possible to prevent the internal full path from reaching the 260-character limit.
  • Encrypt sensitive data stored in isolated storage.
  • Use IsolatedStorageSettings to store objects and simple settings in isolated storage.
  • Use IsolatedStorageFile if you want to use file and stream-based APIs, are storing large amounts of data, or need fine-grained control over the contents of isolated storage.

What is Windows Azure


Want to know more about Windows Azure and it benefits?
How does Windows Azure work?
How does it let you concentrate more on your code and less on operations, maintenance and scaling?
Let Steve Marx from Microsoft draw you a picture.

Introduction to Gestures in Windows Phone 7


A Windows Phone 7 device touch input in the form of gestures. In Windows Phone OS, a touch gesture involves tapping or swiping one or more fingers on a touch screen.
A Windows Phone 7 Application can use the following gestures:
Single-touch gestures
  • Tap
  • Double Tap
  • Pan
  • Flick
  • Touch and Hold
Multi-touch gestures
  • Pinch and Stretch

Wednesday, August 10, 2011

Theme dependent panorama background

Windows Phone 7 provides various theme based resource which change automatically depending on the currently selected theme i.e. dark or light.

You can use these resources for all controls except the case of a panorama background. In such a case you can use a Brush property in your view model to change the panorama background depending on the currently selected theme.


public ImageBrush PanoramaBackgroundImage
{
  get
  {
    var lightThemeEnabled = (Visibility)Application.Current.Resources
["PhoneLightThemeVisibility"] == Visibility.Visible

    var url = lightThemeEnabled ? "/Images/PanoramaBackground_light.jpg"
                             : "/Images/PanoramaBackground_dark.jpg";

    var brush = new ImageBrush
    {
        ImageSource = new BitmapImage(new Uri(url, UriKind.RelativeOrAbsolute))
    };
    return brush;
  }
}

The only thing left is to bind the background of the panorama to this property. You may also need to add a design time value to this field for design time rendering purposes.

Related Links

Tuesday, August 9, 2011

Page Transitions in Windows Phone 7 – Part 2

Previously, I have published some information about page transitions available in Windows Phone 7. I would recommend to read this post to get a summary of what has already been discussed. As I have mentioned before, there are many transitions available from the Silverlight toolkit:
  • Turnstile Transition
  • Swivel Transition
  • Slide Transition
  • Roll Transition
  • Rotate Transition
Lets take a look at all of these transitions in detail.

Turnstile Transition


This transition is similar to turning a page from one corner. A turnstile transitions is the most common and simplest to use.
It has four modes BackwardIn, ForwardIn, BackwardOut and ForwardOut. Like the name suggests these modes are applicable for while navigating in and navigating out.

    <toolkit:TransitionService.NavigationInTransition>
        <toolkit:NavigationInTransition>
            <toolkit:NavigationInTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardIn"/>
            </toolkit:NavigationInTransition.Backward>
            <toolkit:NavigationInTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardIn"/>
            </toolkit:NavigationInTransition.Forward>
        </toolkit:NavigationInTransition>
    </toolkit:TransitionService.NavigationInTransition>
    <toolkit:TransitionService.NavigationOutTransition>
        <toolkit:NavigationOutTransition>
            <toolkit:NavigationOutTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardOut"/>
            </toolkit:NavigationOutTransition.Backward>
            <toolkit:NavigationOutTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardOut"/>
            </toolkit:NavigationOutTransition.Forward>
        </toolkit:NavigationOutTransition>
    </toolkit:TransitionService.NavigationOutTransition>


Swivel Transition

A Swivel Transition is exactly similar to a turnstile transition from a developers point of view. When this transition is applied it appears as if the page comes to the front or from the back vertically.

Sunday, July 24, 2011

Windows Phone 7 Profiler


The Windows Phone Profiling Tool lets developers measure, evaluate, and target performance-related issues in their code. These tools are fully integrated into the Visual Studio IDE to provide a seamless and approachable user experience.
Profiling a phone application is straightforward. You begin by creating a new performance session. After a performance session ends, data gathered during profiling is saved in file with the extension .sap that you can view inside the IDE. These provide views on the different levels of your application structure from source code lines to processes, and program execution data from the calling and called functions of a specific function to the call tree of the entire application.

Read more at MSDN

The Windows Phone Profiler, "In Progress"


Windows Phone Profiler, with highlighted timeline


Related Links

Designing Icons for Windows Phone 7


In Silverlight TV #78, Corrina continues the Design Tips miniseries by sharing her insights on how to create tiles and splash screens for Windows Phone applications. She walks through the process of creating an icon in Expression Design and how to make tiles look good and quickly mesh with Metro. Corrina then shows how to create a splash screen and gives some good tips on how to make the splash screen provide a better user experience. Finally, she walks through some tips to help with working with gradients. This video is packed with tips from Corrina, including some great keyboard shortcuts she uses when working with Expression Design.





The main topics Corrina covers are:
  • Importing photos and using them as a stencil for icons
  • Creating a good splash screen that meshes with your app
  • Simple gradient color solutions
Related Links

Page Transitions in Windows Phone 7

If you see any in-built application on Windows Phone 7, you would notice nice transition effects when navigating from one page to another. These transitions certainly improves the overall user experience of the application.


When you create a new Windows Phone 7 Application using Visual Studio 2010 or Blend, you do not get theses nice transitions in your application.


For this, you would need to add a reference to the Microsoft.Phone.Controls.Toolkit.dll in your project. Once this is done, you would need to use the Transition Service in every page that you want to have the transition effect.



<toolkit:TransitionService.NavigationInTransition>
    <toolkit:NavigationInTransition>
        <toolkit:NavigationInTransition.Backward>
            <toolkit:TurnstileTransition Mode="BackwardIn"/>
        </toolkit:NavigationInTransition.Backward>
        <toolkit:NavigationInTransition.Forward>
            <toolkit:TurnstileTransition Mode="ForwardIn"/>
        </toolkit:NavigationInTransition.Forward>
    </toolkit:NavigationInTransition>
</toolkit:TransitionService.NavigationInTransition>
<toolkit:TransitionService.NavigationOutTransition>
    <toolkit:NavigationOutTransition>
        <toolkit:NavigationOutTransition.Backward>
            <toolkit:TurnstileTransition Mode="BackwardOut"/>
        </toolkit:NavigationOutTransition.Backward>
        <toolkit:NavigationOutTransition.Forward>
            <toolkit:TurnstileTransition Mode="ForwardOut"/>
        </toolkit:NavigationOutTransition.Forward>
    </toolkit:NavigationOutTransition>
</toolkit:TransitionService.NavigationOutTransition>

Copy the above XAML and paste it in your Page, preferebly at the end.


This would enable the tranitions for this page.  Now if you would like thses transitions to work automatically,

Friday, July 15, 2011

Building Mobile-Ready Content and Layout

Smart phones and tablets have changed people's web experience dramatically. If you are a web developer, you would probably require a mobile ready website.

There are two options one create two different sites one for the large screen devices and other for mobile devices.
Managing two different websites and become a difficult task after some time.The solution, build a mobile ready website which can change its appearance depending on the device you are viewing your site.


For this purpose, one must:
  • Focus on creating semantic markup – use CSS and JavaScript for appearance and behavior

Thursday, July 14, 2011

Categorize Custom Properties in Visual Studio or Blend


Many a times when you write your own control in Silverlight, its properties are displayed under "Other" in Visual Studio and "Miscellaneous"  in Expression Blend.

For one or two properties this behaviour is acceptable, but when you are creating custom template controls, usually you have many custom properties. Having these organized in groups makes the life of a XAML designer a bit simple.

So how do you set categories to your properties?

The answer is simple, just place a Category Attribute to your property like this:
[Category("My Properties")]
public string MyCustomProperty{ get; set; }
You can have multiple properties in one group by setting two properties within the same group name.

Related Links

Wednesday, May 25, 2011

Windows Phone 7: Mango preview



Microsoft gave a preview of the upcoming "Mango" release of Windows Phone, through a series of events around the world.

Mango is set to provide 500 new features and enhance the smartphone experience dramatically.

Communications: Easier to Connect and Share
  • Threads
  • Groups
  • Deeper social network integration.
  • Linked inbox
  • Hands-free messaging
A Smarter Approach to Apps
  • App Connect
  • Improved Live Tiles
  • Multitasking
Taking the Internet Beyond the Browser
  • Internet Explorer 9.
  • Local Scout
  • Bing on Windows Phone
  • Quick Cards

Sunday, May 15, 2011

From iPhone to Windows Phone 7


In a very strange move, Microsoft is helping the iPhone developers use their skills to make a Windows Phone 7 application.

Does this mean Microsoft admits that the iPhone is superior to Windows Phone 7 or its just another marketing gimmick from Microsoft to get some attention on the WP7 platform.

Leveraging your iPhone development expertise to build Windows Phone 7 applications on the Windows Phone Developer Blog gives more insights on this topic.

The blog also has a series of “developer stories”, in which developers share on video their experience porting iPhone applications to Windows Phone and explain why and how they did it.


Windows Phone 7 Guide for iPhone Application Developers
If you have been developing iPhone applications and are interested in building your applications for Windows Phone 7, this guide is for you.
The guide will cover what you need to know to add Windows Phone 7 development to your skill set, while leveraging what you have already learned building iPhone:
Source : http://windowsphone.interoperabilitybridges.com/

You may also want to visit Jesse Liberty's tutorial: iPhone to Windows Phone 7 Tutorial.

iOS API call and its WP7 equivalent along with C# sample codes and API documentations for both platforms can be found here.

Related Links

Silverlight 5 - 3D support


The 3D Graphics API was added in the recently released Silverlight 5 Beta.

Having 3D graphics support is a major advancement in Silverlight and is expected to have a huge impact in the near future.

One area where the 3D Graphics API can be useful is 3D Graphics

3D Physics demo




There are a lot of places that you can visit to gain more knowledge about the 3D Physics.
Here are some useful links:
Another nice implementation of the 3D Graphics API is Augmented Reality.
Augmented Reality demo

Useful Links
I would have appreciated more documentation from the Silverlight Team on the 3D Graphics API.
Let's wait and see how these features are implemented by various people. (If you have a good implementation don't forget to ping me)

Sunday, May 1, 2011

What’s Coming In Mango–Reminders


Mango is the next update to Windows Phone 7. Its set to bring a lot of features with it, including something called as "Reminders"

This is what you could be able to do:



What are you waiting for, see this latest post from Jesse Liberty on his blog.

Tuesday, April 26, 2011

Implicit Templates in Silverlight 5


Silverlight 5 has added many new useful features. If you have not read about Silverlight 5's new features then read Silverlight 5: What’s New.

Implicit Templates is one of the new features included in Silverlight 5. Implicit Templates can be said to be data templates associated with a particular data type. These templates will be applied to all template-driven controls which are trying to display the specified data type.

For example, If you have two classes Manager and Employee both derived from the Person class. Now you would like to display the list of people in your company with different styling for each type of person. this is where Implicit Templates make your life easy.

Just specify two Data Templates for each of the two classes i.e. Manager and Employee.

<ListBox x:Name="PeopleList">
<ListBox.Resources>
<DataTemplate DataType="local:Manager">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" FontWeight="Bold" />
<TextBlock Text="(Manager)"  FontStyle="Italic" Margin="5,0,0,0"/>
</StackPanel>
</DataTemplate>
<DataTemplate DataType="local:Employee">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" />
<TextBlock Text="{Binding ManagerName, StringFormat='Managed by: {0}'}" FontStyle="Italic" Margin="5,0,0,0" Foreground="Gray" />
</StackPanel>
</DataTemplate>
</ListBox.Resources>
</ListBox>

This will display some thing like this:


Implicit Templates does allow you to easily specific unique characteristics of an object in your data template.

Another example many people use for Implicit Templates  is Twitter. See this example from Pete Brown. In his post, Pete Brown describes Implicit Templates in more detail. 



Install Silverlight

Video: Pete Brown demonstrates Implicit DataTemplates.

Related Links

Profiling Silverlight Applications


You can profile Silverlight 4 applications, however this task is not integrated within Visual Studio 2010.
Here's what you need to do: open an Visual Studio 2010 Command Prompt in administrator mode and run the following:
VSPerfClrEnv /sampleon
VSPerfCmd -start:sample -output:somefile.vsp
VSPerfCmd -globalon
VSPerfCmd -launch:"c:\Program Files (x86)\Internet Explorer\iexplore.exe" -args:""
VSPerfCmd -shutdown
VSPerfClrEnv /off
This will create a VSP (Visual Studio Profile) file in the current directory, which you can then open in Visual Studio.

Silverlight5 now supports profiling within Visual Studio 2010 SP1.

Related links

Saturday, April 23, 2011

Silverlight Trusted Applications


A new feature Silverlight 5 Beta has introduced is the ability to do some of the “trusted” features in the browser.

This brings the current functionality of trusted applications in current form to be used in the browser context without having to be installed.


This still requires the XAP to have the Elevated Permissions security setting in the manifest as it would exist with out-of-browser applications as well as the XAP being signed (and the certificate in the user’s trusted publisher store).


For example, Multiple window support has been added in Silverlight 5 Beta for Trusted OOB applications. Here's a code snippet from xamlgeek.net

Silverlight 5 supports the ability to open multiple top-level windows. It is required that the application run with elevated permissions.
clip_image001
Closing the main application window will cause all windows to close.
I would be writing more in detail about each of the new Silverlight 5 features in future posts...
For more on how to create a trusted application follow the guide below:

Request elevated trust

Check the "Require elevated trust when running outside the browser" check box in the Out-of-Browser Settings dialog box.
Out-of-Browser Settings dialog box, Require elevated trust option

When users attempt to install an application that requires elevated trust, they are shown a security warning instead of the normal install dialog box. The default warning indicates that the publisher is not verified, and does not display your application icon.

Security Warning dialog box for unsigned application requiring elevated trust

Sign your XAP

You should always sign an application that requires elevated trust to enable verification that you are the publisher. For debugging purposes, Visual Studio lets you create and use a test certificate.
Signing page, project designer

A signed application still displays the security warning at install time, but the message is milder and includes your application icon.

If you would like to know more about application signing visit this MSDN article.
Security Warning dialog box for signed application requiring elevated trust

After installation, the trusted application can access all of the out-of-browser features. Additionally, it is not subject to security restrictions such as user-consent requests and full-screen keyboard limitations.


Related links