Lossandra

I'm working on a project where we would like to store texts for user messages and the like in resx files for internalization. Now I want to display this text in a textblock, but format it (i.e. insert line breaks).

In XAML without resources this is about what I'd like to have:

Code Snippet

<TextBlock TextWrapping="Wrap">
Line1
<LineBreak/>
Line2
</TextBlock>



How would I do this with a resx.string If I create a string

Code Snippet

mystring "Line 1 <LineBreak/> Line2"



and put that into a property of my binding object, with xaml like this:

Code Snippet

<TextBlock TextWrapping="Wrap" Text={Binding Path=myString/>



It does not interpret the <LineBreak/> tags. I'm not sure if I could use a richtextbox, but that would seem a bit overkill to me.

Any ideas Thanks.


Re: Windows Presentation Foundation (WPF) Multliline TextBlock content from resx file

lee d

Did not try it myself, but try including the namespaces for the LineBreak




Re: Windows Presentation Foundation (WPF) Multliline TextBlock content from resx file

Lossandra

I now found a solution, which is not very satisfying but at least works.

Looking at how blend does multiline things, I've gone and tried with a label. For labels it creates &#xd;&#xa; strings instead of <LineBreak/> tags. So I've gone, put those into my resx string. - Did not work.

Debugging into ContentControl and a few hours later, I've found out that if you feed a "\n" to a label as content it will create a newline out of it. However, storing "\n" in a resx will return "\\n" when accessed, but that's what string.replace is here for, isn't it

Somehow this seems a rather cumbersome way of doing it to me though...