WPF Reflections

Oct 26 2007   1:25PM GMT

Removing localisation attributes from xaml



Posted by: Mark Shurmer
WPF

Should you find yourself in a position where you have localised your WPF application, and then wish you hadn’t, you will find yourself needing to remove all the attributes put in by the localisation process.

For those who have yet to experience that, the attribute that is added is x:Uid, like so:

<TextBlock x:Uid=”txtMyTextField” />

The awkwardess is presented by the fact that you want to not only find the attribute in every single xaml element, but to remove the value of the attribute as well.

The first thought I had, no doubt like many others, was that seems pretty basic functionality for search and replace in any xml editor. So I tried my favourite one - no good.
Therefore I tried lots, from basic to industry leaders - even some that half promised on their websites didn’t
:-(

So, I fell back to the last resort which was a regex search and replace in visual studio - which worked, though it’s a whole lot scarier!
Here it is for those looking:

x\:Uid=”[:a\:_]*”

which includes the colon and the underscore in the search pattern

Comment on this Post


You must be logged-in to post a comment. Log-in/Register