Note that there are some explanatory texts on larger screens.

plurals
  1. POFormat Large Block of Text in C#
    primarykey
    data
    text
    <p>I have assigned a section of text to <code>Description</code>. This "Description" is pulled from a text file depending on the <code>id</code> of an item.</p> <pre><code>private string _description = string.Empty; public string Description { get { return this._description; } set { this.SetProperty(ref this._description, value); } } </code></pre> <p>This works fine and returns the description. But it is returned as a large block/wall of text.</p> <p>I tried the following but it doesn't work well, it only formats the defined text and doesn't help me because <code>Description</code> is dynamic.</p> <pre><code> String ITEM_CONTENT = String.Format( "Item Content: {0}\n\n{0}\n\n{0}\n\n{0}\n\n{0}\n\n{0}\n\n{0}", "proin lobortis sollicitudin augue elit mus congue fermentum parturient fringilla euismod feugiat."); </code></pre> <p>I am fitting the description into a TextBlock on my XAML page</p> <pre><code>&lt;TextBlock x:Name="decription" Text="{Binding Description}" FontSize="30" TextWrapping="Wrap" Width="Auto" MaxWidth="1400" LineHeight="35" Padding="20"/&gt; </code></pre> <p>How do I format this <code>Description</code> so that it is neater, with line breaks or new lines after every 5 sentences ending with a fullstop?</p> <p>EDIT:</p> <p>Tried this but still didn't work</p> <pre><code>private string _description = string.Empty; public string Description { get { return this._description; } set { var description = string.Empty; var substrings = "".Split( '.' ); for ( int i = 0; i &lt; substrings.Length; i++ ) { description += substrings[i]; if ( i%5 == 0 ) { description += Environment.NewLine; } } this.SetProperty(ref this._description, description); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload