Class SvgContentList
An element's content in file order: child elements, text, comments and processing instructions. Changes mark the document's render tree for rebuilding.
public sealed class SvgContentList : Collection<SvgContent>, IList<SvgContent>, ICollection<SvgContent>, IReadOnlyList<SvgContent>, IReadOnlyCollection<SvgContent>, IEnumerable<SvgContent>, IList, ICollection, IEnumerable
- Inheritance
-
SvgContentList
- Implements
- Inherited Members
Examples
SvgDocument document = SvgDocument.Parse(Icon);
// Elements, attributes and text are an editable tree, like XDocument's.
SvgElement body = document.FindById("body")!;
body.Attributes["fill"] = "#c33";
body.Attributes.Set("href", "#other", SvgNamespaces.XLink, "xlink");
SvgElement dot = new("circle");
dot.Attributes["cx"] = "12";
dot.Attributes["cy"] = "12";
dot.Attributes["r"] = "3";
document.Root.Children.Add(dot);
document.Root.Children.Add(new SvgComment(" added in code "));
foreach (SvgElement element in document.Root.Elements())
{
Console.WriteLine($"{element.Name}: {element.Attributes.Count} attributes");
}
Methods
ClearItems()
Removes all elements from the Collection<T>.
protected override void ClearItems()
InsertItem(int, SvgContent)
Inserts an element into the Collection<T> at the specified index.
protected override void InsertItem(int index, SvgContent item)
Parameters
indexintThe zero-based index at which
itemshould be inserted.itemSvgContentThe object to insert. The value can be null for reference types.
Exceptions
- ArgumentOutOfRangeException
indexis less than zero.-or-
indexis greater than Count.
RemoveItem(int)
Removes the element at the specified index of the Collection<T>.
protected override void RemoveItem(int index)
Parameters
indexintThe zero-based index of the element to remove.
Exceptions
- ArgumentOutOfRangeException
indexis less than zero.-or-
indexis equal to or greater than Count.
SetItem(int, SvgContent)
Replaces the element at the specified index.
protected override void SetItem(int index, SvgContent item)
Parameters
indexintThe zero-based index of the element to replace.
itemSvgContentThe new value for the element at the specified index. The value can be null for reference types.
Exceptions
- ArgumentOutOfRangeException
indexis less than zero.-or-
indexis greater than Count.