You can still use the template technique, just put the code in the resource section of the xaml file (rather than in the app.xaml file).