If at all possible, we should have the xaml in the xaml files. It doesn't have to be for this release, but I'd like somebody on the team to spend some time improving this. Ideally all the xaml would move, but at the very least this code could be improved by separating the template stuff into its own method and cleaning everything up. The number 130 is hardcoded in a couple places, there is an if/else with identical assignments inside.