Wow, Microsoft acquired Xamarin!


To develop mobile applications today you have many options

  • you can do it native in Swift/Objective C for iOS, in Java for Android or in C# for Windows Mobile
  • you can build a web-app with popular JavaScript-Frameworks like Angular and use Apache Cordova to deploy it to your devices
  • you can build it native in C# by using Xamarin

With the Xamarin-approach you can share your C# libraries between iOS, Android and C#. You can even build the User Interface just once with Xamarin Forms. And the great thing is what you finally get: A full native app for the corresponding platform.

Already last year at Microsoft’s Build conference I and many others expected that Microsoft might announce that they acquired Xamarin. But it didn’t happen. But today, Microsoft let cat out of the bag.

Microsoft acquired Xamarin

That’s great news for us developers. Think about the awesome integration we will have in Visual Studio to build mobile apps for all platforms. And I’m sure that the toolset – which is already today really awesome – will be enhanced and integrated very well. Read more details about the acquisition on Scott Gu’s blog:

Render just the first line of a TextBlock

Sometimes you want a TextBlock to just display one line. For example if you have a huge virtualized ListView that contains many data items and in the DataTemplate you’re using a TextBlock. When the TextBlock has different height, the virtualization leads to some not so nice behavior when scrolling:
The Thumb of the ScrollBar changes its size while scrolling, as the final extend size is not known, as the items in the ListView have different sizes because of multiple lines.

So when you have virtualization, you might want to display your multiline messages in a master-detail-way. Select a single-line-item in the ListView and display the multiline message somewhere else.

But now the problem is, how to tell the TextBlock to render just the first line? Note that I want to adjust the rendering. I don’t want to adjust the strings with a converter or whatever. Just the rendering! :-)

The TextBox has for the single-line-scenario a MaxLines-Property. But the TextBlock does not have this property.
The TextBlock also does not allow to override its MeasureOverride-method to measure the line height and do custom stuff, as this method is marked as sealed in the TextBlock class.

So how could you display only the first line of a TextBlock like this:

<TextBlock TextWrapping="NoWrap">
  Text with

To render just the first line, I use a little trick. I place the TextBlock from above together with a hidden TextBlock with just one line in a Grid. Then I can bind the real TextBlock’s Height to the ActualHeight of the hidden one-line-TextBlock. Here the XAML-code, works like a charm.

  <TextBlock x:Name="txtOneLineDummy" 
             Text="One line" 
  <TextBlock TextWrapping="NoWrap" 
             Height="{Binding ElementName=txtOneLineDummy,Path=ActualHeight}">
    Text with

Note that you could place the hidden one-liner-TextBlock also somewhere else, especially if you have thousands of records that would use a TextBlock via a DataTemplate

Creating a background application with WPF

Sometimes you need to have an application running in the background. Then you don’t want your MainWindow to be visible all the time. Instead you just want to have an icon in the notification area that allows the user to open up the MainWindow and to exit the application. In WPF you can do this easily with the help of Windows Forms’ NotifyIcon-class.

Just add references to System.Windows.Forms and System.Drawing to your WPF-project. Add also an icon-file (.ico) to your project resources. To do this just open the Resources.resx-file in the Properties-folder of your project. Select the Icon-resource and click the Add Resource button. I’ve named it MyIcon.


Then go to the App.xaml.cs and implement it like below. The trick is to never close the MainWindow, as a closed Window cannot be shown again. Instead cancel the closing and just hide it.

using System.ComponentModel;
using System.Windows;
namespace BackgroundApplication
    public partial class App : Application
        private System.Windows.Forms.NotifyIcon _notifyIcon;
        private bool _isExit;
        protected override void OnStartup(StartupEventArgs e)
            MainWindow = new MainWindow();
            MainWindow.Closing += MainWindow_Closing;
            _notifyIcon = new System.Windows.Forms.NotifyIcon();
            _notifyIcon.DoubleClick += (s, args) => ShowMainWindow();
            _notifyIcon.Icon = BackgroundApplication.Properties.Resources.MyIcon;
            _notifyIcon.Visible = true;
        private void CreateContextMenu()
            _notifyIcon.ContextMenuStrip =
              new System.Windows.Forms.ContextMenuStrip();
            _notifyIcon.ContextMenuStrip.Items.Add("MainWindow...").Click += (s, e) => ShowMainWindow();
            _notifyIcon.ContextMenuStrip.Items.Add("Exit").Click += (s, e) => ExitApplication();
        private void ExitApplication()
            _isExit = true;
            _notifyIcon = null;
        private void ShowMainWindow()
            if (MainWindow.IsVisible)
                if (MainWindow.WindowState == WindowState.Minimized)
                    MainWindow.WindowState = WindowState.Normal;
        private void MainWindow_Closing(object sender, CancelEventArgs e)
            if (!_isExit)
                e.Cancel = true;
                MainWindow.Hide(); // A hidden window can be shown again, a closed one not

Now go in addition to the App.xaml and remove the Startup-Uri, so that when you start the application, only the NotifyIcon is added to the notification area

<Application x:Class="BackgroundApplication.App"


Download the sample-project here: Background application

Got the MVP Award 2015 in Windows Platform Development

Woohoo, I’ve received the Microsoft MVP (Most Valuable Professional) award for 2015 in the category “Windows Platform Development”.


To me there’s no other award comparable to this one. The MVP award means that I have the best possibilities to stay and get connected with the most awesome tech-experts and tech-passionate people around the world, inside and outside the Microsoft-Company. I love it!

More about the MVP award:

My personal MVP profile:


Solved: Lenovo, the Clickpad/Ultranav and the missing hardware-buttons (W540 / T540 / W541)

In several models like W540/T540 etc. Lenovo has replaced the hardware-buttons for the Trackpoint with a big Touchpad. It looks like this:


I own a W540 and as a hardcore-Trackpoint-user it’s really a pain not to have the hardware-buttons. 50% of your left-clicks are a middle-click by accident. This happens because you only have that single big Button. Also you need to move your thumb very far to the left/right to do a left/right-click. I often create Powerpoint-Presentations for my talks in the train as I travel quite a lot. When I want to select items in my presentation, those items are suddenly moved by accident as the “big button” thinks I’m using the Touchpad, but I’m using the Trackpoint. I solved that last issue by disabling the Touchpad in the Bios. But still all the other problems are here, that big single button is so annoying and – not mentioned yet – it’s also very noisy.

In the newer W541-model, Lenovo brought the hardware-buttons back. And the model looks completely the same as the W540. But for sure I don’t want to buy a new machine just to get the buttons back. So I contacted Lenovo if they support that part for the older machines. But I never got a response: Twitter @Lenovo, Lenovo forums (see this thread: etc. No answer. Not even a “We don’t know” or “Sorry, we can’t answer this yet”. Just nothing. Ignored.

So I was deeply disappointed with Lenovo. I used a T43, a T61, a T520 and a W540. And before the W540 I never used a mouse. But with the W540 it’s impossible without a mouse. The Trackpad is just crap if you use it with the Trackpoint.

Some weeks ago on Ebay and on other sides the new W541-Trackpad appeared, for around 70$. I decided to order that one and to try it in my W540. I ordered the one in the picture below from here:


It took around two weeks and today I got it. And I successfully use it. Let me explain the steps to put it into a W540.

1/4 Remove the Keyboard, the Keyboard bezel and add the new Touchpad

First you need to remove the keyboard and the keyboard bezel. The “hardware maintenance manual” shows you how to do this. You can download it for the W540/T540 here:

The part of your keyboard below the keys can be moved up, then you find different screws to unwind, six in total. Here you see two of them:


After unwinding all the screws, you can remove your keyboard. Be careful, as there are two cables connected. You just need to rotate the keyboard towards yourself, then disconnect the cables by lifting up the small black connectors. (I recommend using a small plastic-knife for this).


Now after the keyboard is removed, you need to remove the keyboard bezel. First you need to disconnect the cable for the power-button. You find a detailed description how to do this in Lenovos hardware maintenance manual. In the next step you remove 7 screws from the backside of your notebook:


Then turn it around again and lift up the keyboard bezel. Be careful again, as the Touchpad is still connected with two cables. Like for the keyboard, you just need to rotate the keyboard bezel towards you. I had Mickey Mouse with me, giving me some advice. ;-)


You don’t have to disconnect the cables of the keyboard bezel from your notebook. Instead unwind 5 screws (red arrows) for the Touchpad and disconnect the single cable (green arrow).


To disconnect the cable from the Touchpad you need to lift up the small black part – like for the other cables. Now you can remove the Single-Button-Annoying-Nerve-Costing-Touchpad. Here the old and the new side by side.


Now place the new Touchpad with the hardware-trackpoint-buttons in the keyboard bezel. Note that the new Touchpad just needs four instead of 5 screws. Don’t forget to connect the cable as well.


Now go all the steps backwards again. Put keyboard bezel back on your notebook. Connect the cable for the power-button. Add all the screws to the back of your notebook and mount the keyboard back again. Done! This looks (and is) like paradise on earth for Trackpoint users


2/4 Install the driver

Now your hardware is mounted. The next step is to uninstall the drivers for the Synaptics Ultranav from your machine. After a restart install the driver n10gx25w. That one works fine for me on Windows 8.1. I tried some other drivers that didn’t work – for example the one for the W541 notebook. After the driver-installation you need to restart again and now you can use the hardware-buttons.

3/4 Adjust the settings

Everything worked fine on my machine from the beginning – except scrolling / the middle-button. When I clicked the middle-button while the cursor was above a hyperlink, that link was opened in a new tab of my browser. But instead I wanted to scroll. Scrolling only worked when the cursor was not above a hyperlink. That’s a bad behaviour of the system. So I opened up the Mouse properties in the Control Panel. With the driver installed, you should see a tab there called “ThinkPad”. On that tab, set the Radiobutton below “Enable Middle Button” from “Use as middle click” to “Use for scrolling”.


With that setting my Trackpoint and the hardware-buttons are working like a charm. Like it should have been from the beginning for such an expensive machine.

4/4 Enjoy

Now I can enjoy my machine and work with fun without a mouse while traveling, while at home, while working onsite for customers, … yes, I don’t need my mouse at all! Like I would have expected it from the beginning.

About Lenovo

No one is perfect. But I think it’s really a shame that Lenovo does not officially make a statement to this whole mess. To say “We don’t know yet if we’re going to support the older W540/T540-series with that hardware” or even to say “we won’t support older series with the new hardware-buttons” would be still by far better than just being silent, not answering questions and saying nothing at all. That isn’t good marketing and isn’t the nice way to your long-years-customers and Trackpoint-fans. Many might switch to other OEMs in the future, because Lenovo wants for example the W540-owners to buy a new W541. That’s a shame, as the small replacement-part would be sufficient for a lot of them, and the W540 isn’t old. Mine is just 7 months old… Lenovo brought the hardware-buttons back on the new devices, this shows that they know it was a bad idea to remove them…

In my opinion Lenovo should support all the W540/T540 and other Thinkpad users with the missing hardware-buttons with a cheap and supported hardware-upgrade. That’s the way how to keep customers happy, and that’s the way how those customers will buy a Thinkpad again instead of another device.

Bottom line

I’m happy know. If you want to do the same, be aware that you’ll loose your warranty with the steps described above. But having the buttons back is just awesome.


BASTA! Spring conference 2015 – Keynote

This year at BASTA! Spring in Darmstadt/Germany I had a great time (like all the years before at that great conference). I gave three sessions (see Talks) and a keynote together with Jörg Neumann, Oliver Sturm and Mirko Schrempp. The keynote was about Windows 10 and the “change” Microsoft is going through. You can watch it here (in German):

The future of Windows Presentation Foundation (WPF) and what’s coming next

In 2006 I started working with the first preview versions of the Windows Presentation Foundation with my Trivadis fellow Christoph Pletz. We wrote 2007 the very first German article about MVVM and 2008 I published my first book with the title “Windows Presentation Foundation – the ultimate handbook”.

Since then the consultants of Trivadis and I did a ton of big WPF-projects for several customers. During the last year with the hype around AngularJS and HTML5 many customers asked about the future of WPF. Today I’m happy to announce that Microsoft respective the WPF Team shared their roadmap about that bright future. Find it here:

I’m very happy to see that Microsoft invested quite a lot of effort into performance-optimization for the next version. Also the Visual Diagnostics tools in the article with the Live Visual Tree and Live Property Explorer look quite promising. Below a screenshot taken from the article above:


Even Blend has been completely redesigned and supports now differnt things like for example Solution Folders and better Source Control support.

With that next release of WPF I’ll for sure update my book about WPF and bring out a fourth edition next year.


How the Surface RT became the most reliable Server in our house (Co-starring: Azure and Windows Phone)

I loved my Surface RT from the beginning. The reason why I preferred the Surface RT over the Surface Pro was that the Surface Pro was too small for me as a Notebook, and too heavy as a tablet. So I was always the Notebook+tablet-guy, and not the one-device-for-all-guy. But you know, this might change with the Surface 3.

Ok, now to this story. When I bought the Surface 2 (RT) last year, my Surface RT was a bit unused, as the new version was more light-weight and faster. But I haven’t sold my Surface RT, cause I think it’s still an awesome device. My wife and our kids also loved that device, especially for viewing family-pictures, but they also preferred my new Surface 2. So the Surface RT was a bit unused these days. But since 3 months the Surface RT is again the new superstar in our house.

It all started in early spring this year when we had a lot of break-ins in South Germany, and so in the street I’m living with my family. We already had the issue before the break-ins started that we were not able to see who’s on the other side of the front door. So with that break-in-wave I decided to put some cameras around our house, and I had some requirements:

  • Everyone should be able to see who’s behind the front door
  • Everyone should be able to see around the whole house from inside
  • Cameras should have infra-red-support for night vision.
  • I want to access the cameras from everywhere around the world

I asked an electrician for an offer. But it was just too expensive, and additionally he said he needs to slit some walls, which would cause even more costs as additional work is needed to fix all that. Beside those points my “Nerd”-adrenalin was increasing with every day while I was thinking about my requirements. And so I came up that this project is a totally great project for me – just for me (and you, my faithful blog-reader). So I planned to do the whole stuff on my own.

The whole project can be split up into four parts I want to show you now:

  • Installing the IP-Cameras
  • Surface RT as a Central Point
  • Surface RT connected to Microsoft Azure
  • Windows Phone as a Client

So let’s start with Part I

Part 1/4 – Installing the IP-Cameras

After I looked at the footprint of our house intensively, I planned to install 7 IP Cameras. That number of cameras is necessary to see every area around our house. I drilled holes, crimped RJ45 network cables (yes, I didn’t want to use WiFi for that project. Reason is just to keep electric smog as low as possible), branched off additional plug sockets etc. In the end I had the seven cameras connected to my home network via ethernet-switch. The picture below shows this.


After a lot of research I decided to buy IP Cameras from Vivotek, I took the model IP8332. I tested quite a few, and those where in my point of view really good ones and worth the price. They have a 1280×800 resolution, infrared and they support Power-over-Ethernet. Below a picture of two cameras under the roof framework in 4m height (yes, this project also required to buy a new ladder. :-))


Part 2/4 – Surface RT as a Central Point

After I had installed all cameras, I wanted to have a central point in our house where anyone could view them all. Especially the camera at the front door. And that’s where my Surface RT came into the game. I connected the Surface RT also to the same network the IP cameras are in, like shown below.


It took me about 3 hours to build an app that grabs the Video-Streams of my seven cameras, that never closes and that is always running. I placed the Surface RT on a sideboard that stands at a central point in our house. Every time you go to the front door, you’ll pass that point and you can see who’s outside. Here’s a picture what it looks like:


Clicking on one Camera-image will zoom it up to 100% of the screen (of course with a nice animation). In addition I added a USB-to-Ethernet-Adapter to the Surface RT, as we’re turning off our WiFi during the night. But of course the device should still run.

So now I already met three requirements:

  • Everyone should be able to see who’s behind the front door
  • Everyone should be able to see around the whole house from inside
  • Cameras should have infra-red-support for night vision.

Only one requirement is missing

  • I want to access the cameras from everywhere around the world

I thought that’s an easy one, but there was a problem. Let’s look at that problem in an excursion

Excursion: IPv6 and IPv4

My provider gives my only a physical IPv6-address, but no physical IPv4-address. This is called Dual-Stack-Lite (more here on Wikipedia). When I call an IPv4-server, that call goes in the first step via IPv6 to a proxy of my provider, and from there with a physical IPv4-address to the target host. Unfortunately that IPv4-address is shared with many other users. I never noticed that while I was using the web as a client. But now I wanted to serve the camera-images from my Home-Network.

First trial was to do a Port-forwarding on my Router to the IP-Addresses of my cameras. But the problem is, I don’t have a physical public IPv4-address. My IPv4-address is shared with many other users, and it’s the address of the proxy. I’m not able to reach my home-network with IPv4, the call will end at the proxy!

Ok, so only IPv6 will work.

Second trial was to use IPv6. But then the next problem popped up. The whole mobile communications network in Germany (and also in other/most parts of the world) runs still with IPv4. So to access IPv6-stuff from my mobile, I need to go through another proxy that does the translation from IPv4 to IPv6 and back.

Puh, what a mess. When you read in forums about private NAS (Network attached storage)-systems, you’ll find a lot of that IPv4/IPv6-stuff. But I didn’t like the existing workarounds, and I came up with another idea.

I had the idea of the Hollywood-principle that you might know from developing applications: “Don’t call us, we call you”

Part 3/4 – Surface RT connected to Microsoft Azure

Yes, due to the IPv6/IPv4-issue, I’m not able to access my Home-Network from the Internet in an easy way. But I can upload things from my Home-Network to the Internet. So I had the idea to upload compressed images from my 7 cameras every second. So I need a service that does that job.

As I already had a 24h/7days-running-Surface RT-device, I thought maybe the Surface RT could do that job in addition – beside displaying live-images of the 7 cameras.

But where shall I put those images? For me Microsoft Azure seems to be the perfect place. I could create a secure Azure Website or any other client.

Yeah, that sounds good. I decided to go that way down the road. I extended the Windows Store App running on my Surface RT to upload compressed camera images every second to Microsoft Azure. The connection is done via https. The picture below shows the architecture:


As the camera-images are very small, I thought Azure’s Blob Storage would be a bit overkill for that scenario. So I decided to use Table Storage on Microsoft Azure. I created a simple table that contains the current images of all seven cams. And my Surface RT uploads those images every second. And guess what: My Surface RT does this job without break since three months. And everytime we’ve a visit in our house, people say: “Wow, how crazy is that”. And they think the Surface RT is just displaying a live-view of the cams, but you know now, it’s doing more.

(Btw: The costs for Microsoft Azure are below 2€/Month. If you’ve a MSDN-Subscription, you’ll have 150$ for free)

Part 4/4 – Windows Phone as a Client

Now I’ve all my current camera-images available in Microsoft Azure. So I can do whatever I want with them. I decided to create a Windows Phone App just for me. So I can connect with my Windows Phone to the fresh data on Microsoft Azure that is provided by the most reliable server in our house, the Surface RT. The image below shows the final architecture.


The Windows Phone App does a polling on Microsoft Azure. That’s not the best battery-saving-way, but fine if you just want to view if everything is alright at home. Below is an image of my Lumia 920 that runs the application:



As you can see, the Surface RT, Microsoft Azure and Windows Phone are doing their job really really well. It was simple to build up that architecture, and I was able to fulfill all the requirements I had:

  • Everyone should be able to see who’s behind the front door
  • Everyone should be able to see around the whole house from inside
  • Cameras should have infra-red-support for night vision.
  • I want to access the cameras from everywhere around the world

Alright, after a break when I bought the Surface 2 my Surface RT is used again and more than ever before. And everyone in our house is loving it. Today even my youngest daughter (1,5yo) runs to the Surface RT when the doorbell rings to look who’s waiting behind the front door.

Thanks for reading,

Got the Microsoft MVP Award for 2014 in “Windows Platform Development”

Wow, I’ve just received the Microsoft MVP (Most Valuable Professional) award for 2014 in the new area “Windows Platform Development”.


Thanks to all the people who made that possible. Thanks to all the readers of my books & articles, thanks to the participants of my public talks, thanks to the MSDN-team and the forum members, thanks to the colleagues at Trivadis and my Boss Benno and thanks to Microsoft Switzerland for their great support. Thanks to all my friends and a special big THANK YOU to my wife. I love you!

More about the MVP award:

My personal MVP profile:


BASTA! Spring 2014 – slides and demos

At this year’s spring edition of the BASTA! Conference ( I gave three talks:

  • Windows 8.1 – UI Neuerungen
  • All you need to know about XAML
  • Asynchronous Programming with C#

Thanks to all the people who joined my sessions. I hope you liked them. If you’ve any feedback to share with me, feel free to contact me via this link.

You can download all slides and demos here:

Thomas talks