Archive for the ‘Programming’ Category

Nowadays is possible to build an windows store app that will work cross Windows platform, i mean it would work in Windows 8.1, Windows RT and Windows Phone 8.1.

The support for this developing model was announced by Microsoft  sometime ago.

Universal Diagram

This development support was made in 3 phases a first phase when it was supported using defines in the code, a second phase with the Shared code and override concepts (

In my opinion the way Microsoft build this universal development environment was the right one and comparing with the other players i would say that for developer’s this is the better platform.

The universal development model respects the fact that HTML 5 is a first class citizen and with WinJS a way to code natively to all the Microsoft Windows 8.1 platform.

Some months ago i start with a team at Innovagency the promotion of a big Windows 8.1 store app (only desktop and tablet) to Universal APP to bring also the support to the Windows Phone. The original app was developend in HTML 5 and WinJS and this new Universal app will also be developed that way.

When developing a Windows Store Universal app there are a lot of chalenges nowadays and one off them is what native controls exists in the different flavors of the platform. Especially in the case off WinJS controls not all controls had come to Windows 8.1 on the phone.

Microsoft had decided not to implement the following WinJS controls on the Windows Phone.

Object name Description
BackButton object and all its members Not needed. Apps that target Windows Phone should listen for the hardware backbutton event. See WinJS.Application.onbackclick
CellSpanningLayout and all its members Use GridLayout or ListLayout instead.
DatePicker object and all its members Use SELECT and OPTION HTML elements.
Hub object and all its members Replace with the Pivot control. See section above.
HubSection object and all its members Replace with the Pivot and PivotItem controls. See previous section.
SwipeBehavior enumeration Replace with phone-appropriate gestures.
Flyout object and all its members Navigate to a new page or use the Windows.UI.Popup context menus.
Menu object and all its members Navigate to a new page or use the Windows.UI.Popup context menus.
MenuCommand objectand all its members Navigate to a new page or use the Windows.UI.Popup context menus.
NavBar object and all its members Replace with AppBar and AppBarCommand controls.
NavBarCommand objectand all its members Replace with AppBar and AppBarCommand controls.
NavBarContainer objectand all its members Replace with AppBar and AppBarCommand controls.
Rating object and all its members Use SELECT and OPTION HTML elements.
SearchBox object and all its members Use INPUT HTML element with the type attribute “text”.
SettingsFlyout object and all its members Navigate to a new page or use the Windows.UI.Popup context menus.
TimePicker object and all its members Use SELECT and OPTION elements.
Tooltip object and all its members Navigate to a new page or use the Windows.UI.Popup context menus.

Source of this table can be found at Microsoft in the following URL:

This means when building Windows Universal APPs this controls will be considered not supported s cross platform since they are not supported by the rendering engine of Windows Phone 8.1

At this time our reader may say but i had listen/read that WINRT is shared along the distributions of Windows 8.1, true but only partial.

One off the controls that is not shared in WinJS is the DatePicker, the main reason for that is that in HTML and Javascript there are many ways to build Date Pickers, but imagine that you are promoting a Windows Store app that was built-in HTML to a Universal APP.

Or let’s imagine that we really need or want to have the Date Picker the same way you are used to in WinJS when building Windows apps. We understand the Microsoft option but this disruption is not uniform with what happen in the XAML development UI model.

In my team case we were promotion a Windows Store APP to Universal APP and we get in trouble since we have a lot of user interface logic based on the DatePicker.

The optimal solotion would be to have the control in both devives ( phone and desktop/tablets) or at least a control that has the same behaviour and methods.

Sebastian Gomez is a developer who had the same problem and had strat to build a first implementation of WinJS datePicker ( ). The only problem to use this in the context we had present above is that thiss control does not map every methods and properties the original WinJS control have.

Me and my team had extend the explendid work of SebaGomez and anchieve a solution that give us that desired behaviour, we had mantain gomez as the prefix of the namespace as a way to mantain the intelectual property to Gomez.

The instation of the control can be made the same way as a common WinJS control or the original WInJS control of Windows.

First of all you should copy the files  Goomez.UI.DatePickerv2.js (implementation of the date picker ) and rx.lite.js (heper class to make easy the implementation of the DatePicker control) to your development enviroment.

In the view where you intend to instatiate the DatePicker:

– in the head make a reference to the files needed respecting the order of the files



– You can instatiate the control using a HTML tag where you declare the type of the control as being our control, like in others WINJS cases


– you can also instatiate the control dynamic form like you would do with any other WinJs control.

As you would do in a normal WinJS control. The usage of this control in the code is the same you are used to in WinJs controls. We had tried to implement every method’s the original WinJS DatePicker has in their interfaces.

I terms of interface the user experience is similar to the native datepicker avaiable in Windows 8.1.

On challenge the ones who will use this control may feel, is how to interact directly with the control deleting or upgrading information, if that is the case always remember that you are dealing with select box, so remember the DOM concepts and will be as easy to use this control as is with the original DatePicker.

You can get our files from the github public repository amarreiros/WinjsDatePicker_Phone, feel free to use the code and collaborate.

You can also get the original DatePicker from SebaGomez GitHub.

A special thanks to Gomez for the initial code and also to my team in Innovagency who had correct some bugs my extension had.


Last Month Microsoft Potugal had invite me to make 2 sessions at the Microsoft Tech Refresh an event to show the development community what’s new and what’s caming next you can have a look ate the agenda in the figure


I was responsible for the deliver of the sessions  Web Application Development using WinJs and Universal Apps Development using HTML 5 and WinJS.

Was a good experience once more i had discover that few people had explore and know the really potential to use HTMl and WinJS on the development of Windows store apps. Was a great event and i was blessed with a great audience in my sessions very interested people with the potential to raise a technical discussion taht will lead them to learn more.

Thanks Microsoft Portugal for this amazing opportunity and a special thanks to the technical community taht once more had recieve me very well at the stage.

You can find the resources of this sessions at my slideshare.

Windows 8 Security

Posted: November 17, 2012 in Architecture, Programming, Windows 8

One of the main focus of Windows 8 development is the web development community and the idea that this is a great opportunity to make the evolution from Web development to App development. I also defend that theory and i think that this is a real deal and opportunity, but what i always say at the training sessions is that in app development we must consider a lot of little things that some of Web developments normally don’t do.

In my Windows 8 training sessions for WebDeveloper’s one of the things i keep remembering to my student’s is the security and performance mindset a app developer must have.


Today i found at the MSDN magazine a great article about the security part and that follow the same guideline i defend i would suggest to all the Web developer’s that had start to build Windows 8 app’s or to the core Windows 8 developer’s that are in the HTML 5 + CSS + JS to give a look at this.

One of many questions about Windows 8 is how to get the device ID, believe or not is not straightforward and for a long time i even ear many times that this wasn’t even possible. Apparently after RTM this becomes possible.

Many times you need this to grant:

-push notification correct behavior

-to grant that a authenticated app is running from some specific device (can be applied many times to bank and finance problems)

The Device ID is many times called App Specific Hardware ID or ASHWID in windows 8 language.


Today digging around to find the answer i found this great post of Wade Wegner that show us how to get this information in C#, you can read the article here You can also find a more complete description on Windows 8 specification


Basically in C# what you need to do is something similar to

private string GetHardwareId()
    var token = HardwareIdentification.GetPackageSpecificToken(null);
    var hardwareId = token.Id;
    var dataReader = Windows.Storage.Streams.DataReader.FromBuffer(hardwareId);

    byte[] bytes = new byte[hardwareId.Length];

    return BitConverter.ToString(bytes);

In WinJS you would have something similar to

function getHardwareId(outId){
    var token = Windows.System.Profile.HardwareIdentification.getPackageSpecificToken(nonce);
    var hardwareId =;
    var signature = packageSpecificToken.signature;
    var certificate = packageSpecificToken.certificate;
    outId = hardwareId;


Hope this information can be useful for you.


One off the fantastic things about the new Windows Metro Kernel is the language projection that enable us to use almost the same runtime in to different languages the supported language that we prefer.

But…there is always a but isn’t, one-off the reasons to have a set off tools is because tools are made with a propose in mind with a best usage context that is the same story when we are using language programming and technology that’s way we have invented so many.

When developing to Windows 8 apparently many people don´t know that is possible to use in the same app the different languages that windows 8 supports.

This is very powerful and useful especially when using HTML 5 with Javascript. This 2 technologies are very powerful in Windows 8 and consider as a first citizen technologies when talking about building Windows 8 Metro. But Javascript isn’ t Object oriented, Javascript isn’t organized we have different technical approaches to Javascript that allow us to   create this and other skills but we should never go against the nature off a technology or we will louse more than we will gain.

The mix of the best of 2 worlds cn be very powerful when building real powerful apps. Javascript is better for animations ans Jason, but C# is better for security or for long processing quests. In the Programamtic model off windows 8 we can create components in different CLI languages that we can consume from javascript. To do that we should output our file as a WinMDFile, as shown on the figure.

and the we can call our .net functions and classes from the Javascript. This is done from the properties of your project.

Hope this post can be useful, feel free to ask.