[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:

TextBlockLineBreaks

The result is a nicely formatted TextBlock:

TextBlockResultCorrect

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

ResourceCopyPasteTextBlockResult

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:

    cleanResource

    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:

    xmlResourceLinebreak

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

I hope this short guide is helpful.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Prev
[WPDev] How-to create a tile without app title for Windows Phone

[WPDev] How-to create a tile without app title for Windows Phone

Next
I learn to tie my shoes – now available on Windows Phone (deal inside)

I learn to tie my shoes – now available on Windows Phone (deal inside)

You May Also Like

This website uses cookies. By continuing to use this site, you accept the use of cookies.  Learn more