Export (0) Print
Expand All

MinMaxParagraphWidth.MinWidth Property

Gets the smallest paragraph width possible that can fully contain the specified text content.

Namespace:  System.Windows.Media.TextFormatting
Assembly:  PresentationCore (in PresentationCore.dll)

public double MinWidth { get; }

Property Value

Type: System.Double
A Double that represents the smallest paragraph width possible.

The minimum paragraph width corresponds to the word that has the greatest width in the text content.

The following example shows how to use the MinWidth property to generate the minimum paragraph width for the formatted lines of text.

MinMaxParagraphWidth minMaxParaWidth =
    formatter.FormatMinMaxParagraphWidth(customTextSource, 0, customTextParagraphProperties);

// Format each line of text from the text store and draw it. 
while (textStorePosition < customTextSource.Text.Length)
{
    // Create a textline from the text store using the TextFormatter object. 
    using (TextLine myTextLine = formatter.FormatLine(
        customTextSource,
        textStorePosition,
        minMaxParaWidth.MinWidth,
        customTextParagraphProperties,
        null))
    {
        // Draw the formatted text into the drawing context.
        myTextLine.Draw(drawingContext, linePosition, InvertAxes.None);

        // Update the index position in the text store.
        textStorePosition += myTextLine.Length;

        // Update the line position coordinate for the displayed line.
        linePosition.Y += myTextLine.Height;
    }
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft