There is some markup for resources (
 is a analog of \r\n)
<Application.Resources>
<system:String x:Key="key1">Line1
Line2</system:String>
</Application.Resources>
and for main window:
<Grid>
<TextBlock Text="{DynamicResource key1}"/>
<Grid>
But the result is only one line: “Line1 Line2”. What is wrong?
TextBlockignores whitespace when using its Text property. The only way to add line breaks is to use the Inlines property. While this is a read-only property that cannot be set directly, it is also the content property of theTextBlock, and thus can be set like so:You will not be able to use
DynamicResourcethough, since Inlines is not a dependency property.Also, for whitespace to be preserved in XML, you will need to add
xml:space="preserve"to your string (xmlis a predefined namespace, no need to declare it):