MinMaxParagraphWidth Structure

Represents the smallest and largest possible paragraph width that can fully contain the specified text content.

Namespace: System.Windows.Media.TextFormatting
Assembly: PresentationCore (in presentationcore.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public struct MinMaxParagraphWidth : IEquatable<MinMaxParagraphWidth>
public final class MinMaxParagraphWidth extends ValueType implements IEquatable<MinMaxParagraphWidth>
You cannot use this managed structure in XAML.

The following text uses the maximum paragraph width for the source text, which displays as a single line.

Maximum paragraph width


Text displayed using maximum paragraph width

The following text uses the minimum paragraph width for the source text, which displays as multiple lines. The minimum paragraph width corresponds to the word that has the greatest width—in this case, the word "jumped". Notice that multiple words can appear on the same line, as long as the total width does not exceed the minimum paragraph width.

Minimum paragraph width


Text displayed using minimum paragraph width

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;
    }
}

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show: