StyleCollection Class
Represents a collection of Styles.
public sealed class StyleCollection : IEnumerable<Style>, IEnumerable
Public NotInheritable Class StyleCollection
Implements IEnumerable(Of Style), IEnumerable
- Inheritance:
- System.ObjectStyleCollection
Remarks
Used as a container for a Styles property.
Properties
Count
Gets the number of Styles contained in the StyleCollection.
Property Value
- System.Int32
The number of Styles contained in the StyleCollection.
Item[Int32]
Gets the Style at the specified index.
public Style this[int index] { get; }
Public ReadOnly Property Item(index As Integer) As Style
Parameters
index
- System.Int32
The zero-based index of the Style to get.
Property Value
Item[String]
Gets the Style with the specified style name.
public Style this[string styleName] { get; }
Public ReadOnly Property Item(styleName As String) As Style
Parameters
styleName
- System.String
Name of the style.
Property Value
Exceptions
- System.ArgumentException
Style with the specified name is not contained in the collection.
Methods
Add(Style)
Adds a Style instance to the StyleCollection.
Parameters
Contains(Style)
Determines whether the StyleCollection contains a specific Style instance.
Parameters
item
- Style
The Style instance to locate in the StyleCollection.
Returns
- System.Boolean
true if item
is found in the StyleCollection; otherwise, false.
Contains(String)
Determines whether the StyleCollection contains a Style instance with specific name.
public bool Contains(string styleName)
Public Function Contains(styleName As String) As Boolean
Parameters
styleName
- System.String
Name of the Style to locate in the StyleCollection.
Returns
- System.Boolean
true if Style instance with specific name is found in the StyleCollection; otherwise, false.
GetEnumerator()
Returns an enumerator that iterates through the StyleCollection.
public IEnumerator<Style> GetEnumerator()
Public Function GetEnumerator As IEnumerator(Of Style)
Returns
- System.Collections.Generic.IEnumerator<Style>
A System.Collections.Generic.IEnumerator<T> that can be used to iterate through the StyleCollection.
GetOrAdd(StyleTemplateType)
Gets the Style that corresponds to given StyleTemplateType.
public Style GetOrAdd(StyleTemplateType templateType)
Public Function GetOrAdd(templateType As StyleTemplateType) As Style
Parameters
templateType
- StyleTemplateType
The StyleTemplateType instance.
Returns
Style that corresponds to given StyleTemplateType.
Remarks
Gets the Style that corresponds to given StyleTemplateType. If StyleCollection doesn't contain correspondent style, then new style will be added and returned.
IndexOf(Style)
Determines the index of a specific Style instance in the StyleCollection.
Parameters
item
- Style
The Style instance to locate in the StyleCollection.
Returns
- System.Int32
The index of item
if found in the collection; otherwise, -1.
Remove(Style)
Removes the specific Style instance from the StyleCollection.
Parameters
item
- Style
The Style instance to remove from the StyleCollection.
Returns
- System.Boolean
true if the Style was found and removed from the StyleCollection; otherwise, false.
Exceptions
- System.InvalidOperationException
The specific Style is used by one or more document elements.