How to copy a WPF control default template

From MSDN forums user Magnus (MM8) (

Right-click on an element, for example a Calendar, in design mode in Visual Studio 2012 or later and select the “Edit template” option and then the “Edit a copy…” option. This will bring up a dialog that lets you specify the name and location of a style resource that is created for you when you click the “OK” button in the dialog.

There is also an “Edit Additional Templates” option and under this one you will find an “Edit CalendarDayButtonStyle” option that will copy the default template of the CalendarDayButton into your XAML markup.

I did this

I was testing the Office Timeline August 2016 release candidate and the software generated the timeline below. I’m really proud and I am sure I can say without false modesty that it looks awesome. All I did was import data from a Microsoft Project file and then change the default style to Round.


Goodbye, old friend …

Goodbye, C++ , I kind of like much more another programming language now …

Yesterday I had to service a request from a tester: there’s an legacy application that’s still a money maker. It has been developed in Delphi 7 and it uses .INI files to store the application configuration. It’s a pain to maintain it, let me tell you …

There are two INI files containing exactly the same data, something like:










So the tester wanted to split the [Tests] section into three sections, [Tests],[Images] and [Flags], and sort the lines inside the sections by key. I assume this would make it much easier for him to inspect the .INI files (I do not get it why we wants to do that, he should test the application using the black-box method). Of course I’d had to update the legacy Delphi 7 code to properly read and then write back the INI files, which I’ve immediately told his boss was not an option. They’ve accepted instead my solution, which is to implement a command line tool that reorganizes the [Tests] section in a more readable way: all “true tests” together, sorted by key, followed by all “Image*” lines sorted by key, followed by “Flag*” lines sorted by key.

I was not allowed to use C# to implement this utility, because the target systems still run an older version of .NET Framework. So, C++, back to you.

Boy, did I google a lot while writing the tool: how to read .INI files, how to parse the result of GetPrivateProfileSection (in the end I wrote my own state machine for this), how to sort a map (google told me the map is sorted by default by key🙂

I spent a good half an hour figuring how to properly append a char to a string; first, I was calling s.append( c) and the compiler errored with a really unhelpful message. Once I’ve figured I should call s.append(c, 1) the code compiled, but it didn’t work. That’s because the C++ people are thinking backwards when it comes to the order of function parameters, I was calling s.append( c, 1 ) instead of s.append( 1, c ).

Then I was placing the final null terminator over an existing null terminator; another 10 minutes to figure it out.

Another 15 minutes to figure out a normal way to implement string.StartsWith (you should use mismatch for this).

When it was all done and refactored and ready for inspection, I’ve took a good look at the code. Even with auto keyword, iterators, algorithms, STL, the code is much less readable than the C# code. So, goodbye, good old C++ friend (pun intended:-), I’ll enjoy C# even more from now on.

Something to follow

FuzzyDupes:NET Assembly Documentation

Fuzzy text matching algorithms links

Algorithms for Approximate String Matching”, E. Ukkonen.



Excel Fuzzy Lookup Add-In (from Microsoft Research):


Jaro-Winkler algorithm

Cosine similiarity





Bella got its revenge

Yesterday it was a big day for my pets: yearly inoculation day! While Bella deeply enjoys car rides (it’s a dog, after all🙂, Magellan deeply hates being transported by car, especially since it has to do so in a pet box. The first time we tried to travel with it defecated in the box and I had to stop for a clean. Us being its masters, Magellan does not hate us, but it has its ways of protesting.

As my vet told me often, cats have an extra sense – when it’s time to pick them up for the vet visit, they know it well in advance, so they prepare well in advance their escape. Magellan has planned something, but not well this time – it went under the couch. In a moment of inspiration I told Bella to help me, and then I’ve tried a few things to get Maggie out; not a chance, until I’ve got exasperated and I’ve directly lifted the heavy couch. Maggie jumped out, rushing for the alpha site, when Bella put it’s front paw on it, with its entire weight of 8.8 kgs behind it … and Maggie stopped, really stumped.

Easy-peasy then, just picked up the cat, placed inside the pet box and off we went. Bella went ecstatic the entire day. I am certain part of it came from the fact it got its revenge for all the moments the cat has ambushed it.