Multi-Touch Behaviors project moved to GitHub

I’ve just pushed to GitHub a first version of the Multi-Touch Behaviors containing a new sample targeting Windows 10 UWP (work in progress…) and some refactoring using shared projects in order to simplify the code and reusing it across different platforms.

For new contributions just send pull requests here!

Multi-Touch Behaviors sample: Main Page

Windows 10 UWP and Project Westminster: giving new life to your web sites with Hosted Web Apps

One of the most interesting features available in the new Windows 10 Universal Windows Platform (UWP) is the concept of Hosted Web Apps: an existing web site can be easily published to the Windows Store by creating a package pointing to it and, in this case, enabling access to the underlying UWP platform.

This feature enables the developer to easily enrich existing sites with Windows 10 specific functionalities and services like Cortana, Voice recognition, Xbox Live, just to name a few.

The steps required for creating an hosted web app using Visual Studio 2015 are quite simple:

1 – Create a new JavaScript Windows Universal project:

HostedWebAppVs2015_1

2 – Remove all unneeded source files from the project

Since the app will be pointing to an existing web site, the folders js / css / WinJS and the default.html file can all be removed from the project

HostedWebAppVs2015_2

3 – Modify the app manifest to provide the target URL and content rules

The package.appxmanifest file must contain the details of the Start Page and also the content rules specifying if the web site will have access or not to the Windows Runtime:

 

4 – Access desired Windows Runtime functionalities in the website code

I’ve created a very simple web page which will be accessing the UWP platform if the code is executed within an hosted web app. In this case we are only verifying the internet connection, but it could be modified to access Cortana APIs!

 

Here we go. These are the steps required for creating an hosted web app in Windows 10 UWP.

If you want to play with the code, I’ve published the sample on GitHub.

Player Framework Beta 3.0 and Universal Smooth Streaming Client SDK for Windows 10 UWP available

A new version of the Player Framework targeting Windows 10 UWP is now available for download from Codeplex. Smooth Streaming support is provided via the Universal Smooth Streaming Client SDK available in the Visual Studio gallery.

PlayReady is now part of the UWP platform (read the original discussion here), so there is no additional SDK required.

Player Framework 3.0 can also be used on Windows 8.1 Store apps and supports both XAML and WinJS 4.

TypedMVVM and WinJS: Binding event handlers in a ListView ItemTemplate

I have recently received a request in the TypedMVVM forums about binding event handlers to a specific WinJS ListView item template.

I’ve then decided to improve the current samples available in the repository by adding some basic commands, using the RelayCommand<T> class, that can be fired by pressing a button associated to each item of the ListView:

The key here is to add the “win-interactive” class to the specific button element contained in the template (otherwise the click event will not be triggered) and then use WinJS.Utilities.markSupportedForProcessing() in the model to allow the declarative binding to be correctly applied:

Specific instances of the ListView model can be created by the sample service responsible for initialising the ViewModel data:

As usual, the sample code is available for download here.

Cordova Windows Store apps and certificate expired error

I was updating TypedMVVM to the latest Visual Studio 2013 Update 4 and Cordova tools (using the new free Community Edition) and trying to deploy the sample to the Windows 8 emulator when I received the following

error APPX0108: The certificate specified has expired

As pointed here by Microsoft Open Technologies, the certificate available in the Visual Studio template has just expired and is not possible to deploy Windows Store apps using the old one.

To solve this problem I’ve then downloaded from here the updated certificate and copied to the following location inside the Visual Studio project:

res/native/windows/CordovaApp_TemporaryKey.pfx

The updated code is available for download on CodePlex.

TypedMVVM: Samples updated for Apache Cordova

I’ve recently installed the Multi-Device Hybrid Apps template on Visual Studio in order to try out the development of native mobile applications (targeting Android, iOS, Windows Store and Windows Phone) using HTML, CSS and JavaScript using the Apache Cordova framework.

As a first example, I decided to reuse all the TypeScript code available in my library TypedMVVM available on CodePlex.

The process was very simple and didn’t take long: I was able to quickly create a basic “Hello World” application successfully deployed on the Ripple – Nexus 7 Android emulator

TypedMVVM_Cordova

As usual, the updated code is available for download on Codeplex.

WinJS and TypeScript: binding a ListView itemDataSource to a ViewModel property

I’ve recently been asked on the TypedMVVM forums how to properly bind a ListView data source to a list of items available as a property in the ViewModel.

Just create new getters and setters in the ViewModel and initialise the property by creating a new instance of WinJS.Binding.List:

Then reference from HTML the new itemsSource property in the ListView control using data-win-bind:

As usual, the sample code is available for download on Codeplex.

TypedMVVM: Adding a new IoC.Container class for generating instances using generics

In the previous days I was extending my TypedMVVM library with additional classes for separating the logic and being able to use different services for handling operations like showing message dialogs.

I’ve then started the implementation of a simple IoC.Container class that will manage in a centralized way the creation of new objects (ViewModels, Services, etc.) used by the application.

The first step was the creation of a simple Resolve<T> method for creating instances using the concept of Generics available in TypeScript.

When working with factories and generics, it’s necessary to refer to class types using their constructor function:

In this way, a new instance of type T will be returned each time the function IoC.Container.resolve will be used.

For example, it’s now possible to inject a service on a ViewModel in this way:

I’m planning for the future more functionalities for this IoC.Container class, like the possibility to register specific services with interfaces and use them as singletons.

The updated code is available for download from the repository here.

WinJS – Adding a reference to an existing Universal shared project from your Windows Store / Windows Phone app

In the past days I was trying to reference an existing “Universal Shared” project from a Windows Store app, but it seems like that the “Add Reference” functionality is still not available on Visual Studio for shared projects when using WinJS or generic JavaScript Universal apps.

I’ve then verified the default Universal apps template and found that every project is referencing the “Shared” one using this Import block in the .jsproj file:

To enable it for your project, just open the “Solution Explorer” in Visual Studio and:

  • right-click the project and select “Unload Project“;
  • select “Edit <Your-Project-Name>.jsproj“;
  • add the “Import Project” block using the code editor and save it;
  • right-click and select “Reload Project“.

The shared project code should now be correctly referenced and available in your original app.

Same technique can obviously be used by Windows Phone 8.1 solutions (or other targets / platforms).

Universal Windows Apps, WinJS and TypedMVVM: samples updated to target Windows Phone and Windows Store apps

I’ve just returned from the Build 2014 conference in San Francisco where I had the opportunity to attend several interesting sessions about new developments in the Microsoft space.

One of the “big news” has been the introduction of the concept of “Universal Windows Apps“, a great way to share code between different platforms including (but not limited to) Windows Phone, Windows Store and Xbox One apps.

I decided to test this new feature on TypedMVVM, one of my “pet projects” which I made available on CodePlex some time ago. The project was originally using a simple MVVM infrastructure targeting Windows Store apps using WinJS and TypeScript so it was an ideal candidate for adding a Windows Phone 8.1 target reusing all the existing code.

The migration to Universal Apps was really straightforward: I was able to have the samples up and running in my emulator and devices while waiting at the airport in San Francisco.

TypedMVVMWindowsPhoneSample

TypedMVVMWindows81Sample

I’ve uploaded all the source code on Codeplex here, feel free to grab and give it a try.

Happy universal coding everyone! 🙂