Checking for design mode in Xamarin.Forms

Visual Studio for Windows and Mac now includes Xamarin XAML Previewer, which allows you to preview your Xamarin.Forms XAML without having to launch the app. Unfortunately, there are times when your page constructor contains code that cannot be run in design mode (for example service resolution, etc.) and causes the previewer to crash. Can we easily check if the app is in preview (design) mode?

XAML Previewer
XAML Previewer

Continue reading “Checking for design mode in Xamarin.Forms”

Experiencing HoloLens at BUILD 2015

This year for the second time around I attended Microsoft Build 2015 developer conference in San Francisco. Among the biggest highlights of the show was the demonstration of Microsoft HoloLens – the revolutionary holographic reality device coming with Windows 10. I was lucky enough to be able to experience it first hand so I would like to share it now with you.


Register, quickly!

In the first day’s keynote speech it was announced, that the some of the attendees will be able to try out the HoloLens experience for themselves by registering through a dedicated website. One thing that was noted was the fact that the registration will be open right after the keynote ends and it is able to accommodate just a small portion of the large number of developers who are present on the event.

So I acted fast! After the keynote ended I quickly browsed the registration web site on my phone (slowed down by the extreme traffic that all available Wi-Fi networks in the area were getting) and was offered with a choice of three different activities – the Holographic Academy, Holographic presentation and HoloLens One on One. Of the three the One on One session offered the exact activities that were demonstrated in the HoloLens video ad, so I naturally thought of it as the best choice. Sadly, when I tried to choose that activity, my phone (in early preview of Windows 10 Mobile) decided, that the Holographic Academy was the better choice and sent this as my choice. And in the end, I was glad, this one was actually the right one for me!


After an hour, just before lunch, I was lucky enough to receive an invitation in my mailbox to attend the Holographic Academy in a nearby five-star hotel. I had just about 30 minutes to get there so I packed my lunch in the bag and run directly there.

The preparation

In the hotel’s reception area all the invited attendees were anxiously waiting for the signal of the HoloLens staff members that directed them to their chosen activities. The Holographic Academy participants were apparently the largest group and the waiting to be let in was appropriately the longest.


When all was ready, we were let in the elevators to a floor that was dedicated to Microsoft for the purposes of this event.

Right in front of the entrance hall in a glass cube was the Microsoft HoloLens itself for display, but no touching or photography allowed!

We were led to a registration area to sign NDA and had to agree with the fact that we were going to be recorded for demonstration purposes and were handed out a locker key to be able to safely store our personal belongings and all electronic devices, which were of course not allowed on the event itself.

WP_20150704_14_43_46_Rich (2)

Then we had received our badges and got a measurement of the distance between our eyes. This was for our reference later when we had to configure the initial setup of the device for the optimal experience.

Enter the dev area

After all the formalities were finished and everyone was lined up, we were divided into pairs and each pair of attendees was assigned a supervisor, which acted as our personal assistant throughout the afternoon.

With our supervisor we entered the room where the whole event was about to happen. This room was a medium sized conference hall with a stage in the middle and several sections around it. Each section had a conference table surrounded by three to four tables with two computers each. Every each of us was assigned a seat and a dedicated development machine. Surprisingly, there was no HoloLens on sight yet!

The atmosphere of the room was awesome. The anticipation was palpable and it was clear everyone was eager to get their hands on with HoloLens. In the video below you can see for yourself (by the way, you can catch me at the 0:06 mark).


After everyone was in the room and the doors were closed, the one of the event’s presenters entered the stage to introduce us. After a short speech about the device itself and the technology behind it, we were finally handed out the HoloLens device that was going to be “ours” for the rest of the event.

Mind you, HoloLens back then was still in its preview phase. The device no longer required a large battery backpack as in the previous demonstrations and looked like a finished product, but the true holographic version of Windows 10 Holographic was not yet present on the device for example.

Our supervisor helped us set up the device using a preliminary web interface that acted as a temporary substitution for the device’s “so far” non-existent OS interface and allowed us to directly install application packages on it. The OS itself was just an environment where the apps run (just as the Windows IoT Preview looks).


Hello, holograms

After we finished the initial setup we could install our first sample application on the device.

After the app installed, we could finally put the device on. The first great surprise – HoloLens is amazingly light. Although it is a full-fledged computer with high processing power and multitude of sensors, it is really easy to wear and when adjusted correctly it doesn’t even lie on the nose and is extremely comfortable.

The sample application allowed us to place a toy car on any surface around us and then using our gaze and hand gestures instruct the car to drive around the environment. The car was intelligent enough to avoid real world obstacles and was even able to perform stunts like jumping from the table to the floor or driving over my own shoe. All this was extremely realistic as if the car itself was truly a physical object aware of its surroundings and the intricacies of three dimensional reality. The feeling that something like this is being created and presented to me through the lens of a small device on my head was profoundly impressive. This is what is called a mind-blowing experience.

Another thing worth noticing was the image’s stability. No matter how I moved around, the toy car was perfectly stable and didn’t move a bit from its “real world” position. This was maybe even more surprising. I have no idea how the team behind HoloLens was able to achieve this level of stability. Day before the Holographic academy I had a chance to try out the Oculus Rift and I have to say that the difference between those two was like night and day.

Sure, you are probably waiting for me to comment on the field of view, that was described as the biggest setback of HoloLens. Yes, the FOV of the device is smaller than was demonstrated in the previous live showcases and in the advertisements and Microsoft acknowledged that this is a drawback that has to be accepted for the initial release of the device targeted for businesses and developers. I suppose it is mainly an issue of battery life and expect that the second release will expand the field of view enough to be usable for immersive gaming for example. However, I do not feel the field of view was small for normal usage. Most of the objects are visible completely without problems, only a close-up view can cause some cropping of the holograms, which I find more than acceptable.

Let’s //build/!

To bring us back to reality, a bell announced that we should take off HoloLens and come back to pay attention to the stage.

The presenter walked us through the agenda of the rest of the event. We were going to build our first holographic application and become the first developers outside Microsoft to try building for HoloLens.

Our main tools were Visual Studio and Unity – both in pre-release internal beta versions. Unity had a special HoloLens SDK installed that contained prepared tooling for building holographic applications with things like spatial mapping, holographic camera and ambient sound.

Throughout the afternoon we went through the following stages of building a simple app called Project Origami.

Stage 1: Display a hologram

The first and basic stage was just displaying the 3D object in space in front of us. We dragged an pre-composed scene of a origami paper creation in the scene in Unity and placed the Holographic camera.

After preparing the scene, we exported the app as a Windows 10 app and then opened the solution in Visual Studio to allow its deployment to HoloLens itself.

Stage 2: Gaze

First interaction to add to our model was gaze. This enabled HoloLens to track our eye movement and highlight the spot we “look” at. This eye tracking was once again very precise.

Stage 3: Air tap

The second phase of the tutorial added hand gesture – so called air tap. The 3D model contained two paper “balls” levitating in the air. Gazing on one of the two balls and using the air tap gesture, the ball suddenly gained gravity influence and fell down on the floor. In this part of the demonstration however it fell right through the floor into infinity.

Stage 4: Voice

Next up we added voice control as an alternative to the hand gesture. Using our voice we could cause the paper balls to fall and also reset the scene. This made the interaction more natural and demonstrated the freedom the user of HoloLens has when choosing the form of input appropriate for the specific situation. Also worth mentioning is the fact that HoloLens does react only to you and is not confused with people around saying the same thing.

Stage 5: Spatial mapping

To make the holograms aware of the surroundings we added spatial mapping. This was just another of the prepared “plug in” elements in HoloLens SDK for Unity. We just added it and it worked – we could place our hologram on any surface around us and then the paper ball no longer fell down through the floor but correctly interacted with the object around including the table or a sofa.

We were even able to see how HoloLens “sees” the world. Spatial mapping creates a virtual “wireframe” of the environment and very precisely captures the shapes of objects around us.

Stage 6: Ambient sound

To make the experience even more realistic, we added ambient sound. Firstly, the hologram itself exuded a calm, relaxing music and also the falling and rolling of the paper balls was accompanied by sound effect to make them feel real. HoloLens has great sound system built in so the user actually hears the sound as coming from a distance in the right direction. Turning your back to the hologram it sounds like it is truly behind you. Coming closer makes the sound louder. It sounds like a small detail but it makes the experience unimaginably more complete.

Stage 7: A bonus!

To make the experience complete, there was a bonus ready for us at the end of the tutorial. We added an object that was not described more closely to us. When we tried the app then, the falling paper ball caused the floor to break on the impact and revealed a fantasy world below the crack, full of living paper cranes flying around.

Overall impression

Microsoft HoloLens is truly a remarkable technology that sounds, looks and feels like future. I was really blown away by its power and potential and I am sure that anyone who will have a chance to try it will experience the same.

Building apps for HoloLens is be possible in the same way as all other Windows 10 Universal apps. Normal apps will normally work on HoloLens, but if you want to go beyond the boundaries two dimensions, which I definitely recommend, you will really appreciate Unity development environment and the easy-to-use tooling that is at your disposal. Even in its preview form the SDK was extremely straightforward and capable.

The first public release of the hardware is not too far away and I am looking forward to see how the device evolves and what creative uses it can have not only for users, but also for enterprise and even healthcare.

Microsoft has really created something revolutionary here.

Windows 10

Microsoft Windows 10 was released on 29th July to the public.

The newest iteration of the number one operating system in the world of PCs brings along a myriad of enhancements and improvements which make it a perfect choice for everyone using a previous version of Windows or a sub-par OS like Mac OS X.

Best of all – it is free for all users of Windows 7 and Windows 8 who upgrade within the first year of its availability.

One Windows

The most important feature for me as a developer is the fact that Windows is now one and the same operating system on all devices – phones, tablets, notebooks, desktops, IoT devices, Surface Hub workstations, Microsoft HoloLens, Xbox One – you name it and all apps will work on it! Microsoft achieved something incredible here – an unified API and runtime, that spans every device in your life. And even better – the apps are able to adapt easily to the device they are running on and behave just as you expect them.


No other company (nor Google nor Apple), is able to achieve this, ever. No other technology company has an operating system that can span such a varied range of devices and even less a application runtime that can run everywhere without much hassle. This is a huge advantage for both customers and developers and is sure to bring a huge number of apps to the Windows ecosystem. By the way – do you know that Android and iOS apps will be able to run on Windows 10 without almost any changes? Surprised? No – this is Microsoft. Now there is no reason for developers to resist building or releasing apps for Windows and the OS has now the potential to have the largest app offering of all.

Start is back

I have to confess – I have loved Windows 8. Many people hated the new user interface it brought, but I loved the modern and fresh approach the system chose.

That being said, I love Windows 10 even more, if that is even possible.


The Start menu is now behaving in exactly the way that makes sense for the device and work mode you are in. Want small contextual menu on desktop? Check. Want full-screen immersive experience when working with the device as a tablet? Check.

The new Start menu also blends seamlessly the world of tiles with classic applications and the result is extremely satisfying.

Modern apps done just right

One of the criticisms Windows 8 received extremely often was the fact that it was no longer “Windows” – modern apps ran in full-screen or snapped mode, unable to be easily integrated in the classical desktop workflow.

This changes drastically with Windows 10 – Modern apps are first-class citizens of the desktop and work just as you expect them with full resizing support, ability to open multiple windows and much more.

The great thing is that all “old” Windows 8 apps work as well without the need for rewriting any code. Because the apps were written with adaptivity to snap mode from the start, resizing is very well supported. This is a stark difference to the likes of Apple iOS, which just now introduced a very limited and half-baked multitasking support for the iPad (well at least for the latest model – because they need to make money, right?), that requires a complete rewrite of the user interface for most apps.


The current PC market is filled with devices that can be described as “hybrid” and “2 in 1” devices like the Microsoft Surface Pro. These devices offer the traditional looks of a notebook, but can be transformed into a touch-enabled tablet.

Windows 8 was the touch-first operating system. While offering great usability with your fingers, the mouse and keyboard input was a bit less satisfying. Now that changes drastically with Windows 10.

Windows 10 adapts to the way you currently use your PC. As I mentioned – this automatically includes the Start menu, but also includes all your apps. In the tablet mode, that is automatically triggered when you disconnect or flip the keyboard, all apps go full-screen which is the logical way to use a tablet. You can still do multitasking of two apps at the same time, of course. When you need to have a more powerful workstation, just reconnect the keyboard and go into the classic desktop mode. The transition is seamless and logical – just the thing you would expect from an operating systems that understands your needs perfectly.

Tento příběh je však ještě zajímavější v případě mobilních telefonů. Nová zařízení s Windows 10 Mobile umožní připojit telefon k obrazovce a následně jej využívat jako plnohodnotný počítač. To je snem každého business uživatele. Jedno zařízení, které vystačí na opravdu každý úkon.


The first and only true personal assistant Cortana is now on your desktop PC. All features of the phone version are present – including her witty answers and remarks, funny quotes, weather checking, reminders, sports and travel tips, finance tracking and much more. On top of that several new features were added – composing a quick mail message on the fly or finding tips on Windows usage are welcome additions to the growing arsenal of Cortana’s abilities.

cortana-windows-10And we are still just getting started! Now that Cortana will be available on all operating systems including iOS (including iPad – sorry Siri) and Android (with the ability to directly replace Google Now), we can expect a fast paced tempo of new features and additions to her smarts. Cortana learns about the user in a controlled way (all privacy settings can be controlled by the user), so she can be proactive and help directly with the things that matter most.

Microsoft Edge

The new Browser (B uppercase intentionally). Microsoft decided to retire the Internet Explorer to bring a whole new browser for Windows 10 that matches and outperforms all other browsers on the current market. With automatic updates and latest features, Microsoft Edge is the best thing that happened to browsing on Windows ever. Although it is still in its starting phase, it already offers a great and seamless user experience and is amazingly fast and stable.

Snap assist

Windows 7 brought the productivity revolutionary feature of snapping apps to the sides of the screen. This automatically resized the apps to match the half of the screen and made multitasking a breeze. Now Windows 10 improves on this idea with Snap Assist.


This feature goes beyond the original offering by enabling snapping to corners as well as to the sides of the screen and then offering the user a choice of which complementary apps to place on the screen. It may look like a small improvement, but it goes miles in the usability of the snapping feature.

Windows Feedback

This is something the users should be most excited about.

In contrast with Apple’s and Google’s approach of making changes without any regard to the needs and wishes of the users, Microsoft chose a completely new way of building this new iteration of Windows. Windows 10 was built from the start with direct input of its users. Microsoft announced the beta testing of Windows 10 for tech enthusiasts friendly names Windows Insiders.


Through a dedicated app Windows Feedback can now all users send their ideas for changes and improvements directly to Microsoft. All ideas are considered and used to improve the OS, so you should definitely sound off your opinion, vote for good ideas, because it actually counts!


Windows is for doing. Whether you are an professional, designer, creative, business person, gamer – Windows 10 is made for you. I encourage you to upgrade and enjoy the best Windows ever. The best OS ever.

And yes, Microsoft is cool again.



Replacing [ExpectedException] in WinRT unit test library

Recently I needed to write an unit test for my Windows Store application, that would check if a code snippet caused an expected exception. Usually this is done in the following manner:

However, the Unit Test Library for WinRT lacks the ExpectedException attribute.

Luckily, it was replaced by a far more convenient and useful method  Assert.ThrowsException :

You need to provide the type of expected exception as the type parameter of this method and then a lambda expression (or   Action  instance), that contains the code that should throw the exception.

Accessing WebView cookies in WinRT

In my recent Windows 8.1 app project I needed to take advantage of ASP.NET Identity to authenticate in my ASP.NET Web API service. Because Identity offers social (external) logins on top of classic login flow, I decided to integrate them as well. Unfortunately the authentication process required the use of cookies, which needed to be forwarded to the registration endpoint to complete the registration process of a new user. Because the process itself is initiated in a WebView control, we need to obtain the resulting cookies. But WebView does not expose any properties to access them. What can we do?

Continue reading “Accessing WebView cookies in WinRT”

StorageApplicationPermissions in WinRT

Windows 8 and now also Windows Phone 8.1 enable apps access to the filesystem. This API is very limited unfortunately (primarily for security reasons), so by setting several Capabilities in app’s manifest you can access directly just a few basic pseudo-folders – libraries Pictures, Music and Videos (and for enterprise apps in Windows 8 also Documents), but access to other folders directly is only possible through pickers. These return a non-persistent file/folder object, that can’t be accessed after the app closes or terminates.  StorageApplicationPermissions class comes to the rescue. Continue reading “StorageApplicationPermissions in WinRT”

Removing touch highlights on smartphones

When you are testing your websites on your favorite smartphone, you might find out, that Windows Phone and iOS are including a special behavior when any links on the page are pressed – sort of a highlighting – graying out of the active touched area. This is of course quite helpful sometimes when the bounds of active links on the small screen are hard to discern, but at the same time it can in some cases be quite unfriendly and interfering with your site’s design.

How can we prevent it? Let’s see for both operating systems! Continue reading “Removing touch highlights on smartphones”

Showing more stuff on Windows 8.1 tablets and laptops

I recently discovered a great feature of new Windows 8.1 Modern UI, that enables owners of high resolution tablets and laptops to display much more content at once (for the price of making things smaller).

Microsoft Surface Pro 2 with Full HD display will by default show the Start Screen in a fashion similar to this: startscreennormal

As you can see I get four rows of medium sized tiles. Also in normal setup, the device is capable of showing at most two Windows Store apps at once with multitasking.

Now let’s try to tune it up a little!
Continue reading “Showing more stuff on Windows 8.1 tablets and laptops”