Solved

How can I add an enter to a ResourceDictionary element?

Posted on 2013-06-28
3
423 Views
Last Modified: 2013-06-28
Dear Experts-Exchange:

I am attempting to include an enter into a ResourceDictionary element (Example: x:Key="CustomerName").  Bellow you will find a snipet of the ResourceDictionary I refer to:

<ResourceDictionary 
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
	xmlns:system="clr-namespace:System;assembly=mscorlib">

	<system:String x:Key="CustomerName">Customer 
Name</system:String>
</ResourceDictionary>

Open in new window


I will appreciate your reply.

Best regards,

Conrado
0
Comment
Question by:Conrado ZAVALA
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 250 total points
ID: 39285670
As most XML parser, by default the XAML parser skip white space (space, carriage returns, line feeds). You need to tell the parser that you want to keep the carriage return in your string, and then use the standard xml escape code for a carriage return:

<system:String x:Key="CustomerName" xml:space="preserve">Customer&#10;Name</system:String>

Open in new window

0
 

Author Closing Comment

by:Conrado ZAVALA
ID: 39285728
Hello James.  You have no idea about how much this solution mean to me.  Thank you very much (honestly).

Best regard,

Conrado
0
 
LVL 40
ID: 39285807
It also means to me.

My main type of development is done with Windows Application projects, and the resource files they use, although they are also in xml, are a lot easier to use when you need a carriage return inside of a string value.

I am just learning to program Windows Store applications, so the ResourceDictionary is something I am just beginning to use. I started answering your question thinking that it would be as easy as in a Windows Application, where a simple Shift-Enter in the resource file does the trick. When I tried in in a ResourceDictionary, it did not work.

I had some free time, so I went out to find the solution. As is almost always the case with those things, finding the solution is a nightmare. You always find 20 different ways to do the thing... and none of them works. The fact that Silverlight, WPF and Windows Store projects use basically the same concepts but with little annoying differences is a nightmare.

I finally was able to make the thing work in my environment by combining 2 different solutions that were supposed to work separately but did not until they were combined.

I learned something that will be useful to me in the future. So, thanks for your question.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question