?
Solved

How can I add an enter to a ResourceDictionary element?

Posted on 2013-06-28
3
Medium Priority
?
428 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 1000 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

800 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