0

I wish to add a Label in WPF that displays string from two different DynamicResources.
I want each DynamicResource to be on a new line.

My existing code is:

<Label x:Name="MyTextDisplay"  
       Grid.Row="3"
       Grid.ColumnSpan="2"
       Background="Red"
       BorderBrush="Blue"
       BorderThickness="1"
       Margin="2, 2, 2, 2">
    <TextBlock TextWrapping="Wrap" Text="{DynamicResource MyTextLine1}" Grid.ColumnSpan="2"/>
</Label>

I have another DynamicResource called MyTextLine2 that I want to display below MyTextLine1 but in the same Label.

How can I do this?

I have looked at these examples here but they dont display on new lines: How to bind multiple values to a single WPF TextBlock?

Community
  • 1
  • 1
Harry Boy
  • 4,159
  • 17
  • 71
  • 122
  • try changing the Label's datatemplate. Have a grid or a stackpanel and that should do. http://stackoverflow.com/questions/3409587/how-is-it-possible-to-stuff-a-grid-inside-a-textblock – Master Nov 11 '16 at 15:46
  • Use a `StackPanel` inside `Label`and put your `TextBlocks` in that. – AnjumSKhan Nov 11 '16 at 16:45

1 Answers1

0

I faced the same problem and finally I found a solution. Just use \r\n linebreak instead of just \n. So, your resourse must look like:

 <system:String x:Key="MyText" xml:space="preserve">Line 1&#10;&#13;Line 2</system:String>

I realy don't know why this notation must be used only for dynamic resources, but it works for me