Version

DisplayChars Property (XamMaskedEditor)

A collection of the display characters used in the control. Returns a valid collection only if the mask has been parsed yet.
Syntax
'Declaration
 
Public ReadOnly Property DisplayChars As DisplayCharsCollection
public DisplayCharsCollection DisplayChars {get;}
Remarks

Returns a collection of display characters. When mask is parsed, result is a collection of sections where each section corresponds with a part of the mask. Each section in turn has a collection of DisplayCharBase derived objects each of which correspond to a placeholder character in the part of the mask associated with the section. DisplayChars returns the aggregate display character instances from all sections.

See Sections for more information on potential usage of this and Sections property.

Example
The following code demonstrates Sections and DisplayChars property. It sets the Mask and Value properties and prints out the contents of the Sections collection and DisplayChars collection. The Mask and Value property both influence what the following will print out.

Private Sub Button1_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
        Me.maskedEditor1.StartEditMode()

        Me.maskedEditor1.Mask = "###-aaa"
        Me.maskedEditor1.Value = "123-XYZ"

        Dim sections As SectionsCollection = Me.maskedEditor1.Sections

        ' The follwing will print out sections. Sections are based on the 
        ' mask. The mask we set above has two edit sections and one 
        ' literal section.
        Debug.WriteLine("Sections: ")
        Debug.WriteLine("Sections(0) = " & sections(0).GetType().Name)
        Debug.WriteLine("Sections(1) = " & sections(1).GetType().Name)
        Debug.WriteLine("Sections(2) = " & sections(2).GetType().Name)

        ' Like sections, display characters are also based on mask.
        ' The following will print out all the display characters.
        ' It will print out the type of each display character and the
        ' character value associated with the display character (which
        ' comes from the Value that we set above).
        Debug.WriteLine("DisplayChars: ")
        Dim displayChars As DisplayCharsCollection = Me.maskedEditor1.DisplayChars
        Dim i As Integer
        For i = 0 To displayChars.Count - 1
            Dim dc As DisplayCharBase = displayChars(i)
            Debug.WriteLine("DisplayChars(" & i & ") = " & dc.GetType().Name & " '" & dc.Char & "'")
        Next
    End Sub
public void button1_Click( object sender, RoutedEventArgs e )
{
	this.maskedEditor1.StartEditMode( );

	this.maskedEditor1.Mask = "###-aaa";
	this.maskedEditor1.Value = "123-XYZ";

	SectionsCollection sections = this.maskedEditor1.Sections;

	// The follwing will print out sections. Sections are based on the 
	// mask. The mask we set above has two edit sections and one 
	// literal section.
	Debug.WriteLine( "Sections: " );
	Debug.WriteLine( "Sections[0] = " + sections[0].GetType( ).Name );
	Debug.WriteLine( "Sections[1] = " + sections[1].GetType( ).Name );
	Debug.WriteLine( "Sections[2] = " + sections[2].GetType( ).Name );

	// Like sections, display characters are also based on mask.
	// The following will print out all the display characters.
	// It will print out the type of each display character and the
	// character value associated with the display character (which
	// comes from the Value that we set above).
	Debug.WriteLine( "DisplayChars: " );
	DisplayCharsCollection displayChars = this.maskedEditor1.DisplayChars;
	for ( int i = 0; i < displayChars.Count; i++ )
	{
		DisplayCharBase dc = displayChars[i];
		Debug.WriteLine( "DisplayChars[" + i + "] = " + dc.GetType( ).Name + " '" + dc.Char + "'" );
	}
}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also