[WPDev] Add Multiline Text to a Resource File in Windows Phone

Today I had to solve the problem that I needed to add multiline text into my resource file. I did not find a Windows Phone specific solution, but enough hints to solve the problem.

Here is a short guide for you:

First I added a TextBlock control and formatted it in XAML with Linebreaks:


The result is a nicely formatted TextBlock:


Now I tried of course to copy and paste the string in my resource file, and got an ugly result:


As mentioned above, I found out enough hints to solve this problem. There are two ways to solve it:

  • The simple way is to add your text, and for each new line press “Shift+Enter”. The result looks like this in your resource file:


    Please note that you have to click inside of the value field to display the whole content.

  • The second way is to edit the XML-File directly. To open the resource file in XML-mode, right click your resource file and choose “Open with..”. In the following menu choose XML (Text)-Editor. Locate your resource string. Also if it looks not nice in code, you have to format your entry like this:


Both methods will result in a nicely formatted multiline TextBlock after building your app again.

I hope this short guide is helpful.

Posted by msicc

.NET Dev at day & night, Geek. Father of 2 teenagers, husband of a fantastic wife. Founder of MSiccDev Software Development. Opinions are mine.