LiveChartViewModel.ChartObjectsCollection property¶
Defined in
Type: LiveChartViewModel
Namespace: CrissCross.WPF.Plot
Assembly: CrissCross.WPF.Plot.dll
Applies to
net10.0-windows10.0.19041, net9.0-windows10.0.19041, net8.0-windows10.0.19041, net481
public QuaternaryList<ChartObjects> ChartObjectsCollection { get; }
Summary: Gets the collection of chart objects representing line settings. This collection is automatically populated when plot lines are created.
Returns: QuaternaryList<ChartObjects>
Remarks
IMPORTANT NOTES:
- Items are LIVE references - changes immediately affect the chart
- Collection is CLEARED and REPOPULATED on reinitialization
- Do not hold long-term references to items - they may be disposed
- ItemName may initially be "---" until first observable emission
- Access must occur on the UI thread (not thread-safe)
- Items are NOT disposed when collection is cleared - they remain owned by PlotLinesCollectionUI
Lifecycle:
- Updated via UpdateChartObjectsCollection() after InitializeGenericPlotLines
- Items disposed only when ClearContent() is called on parent ViewModel
- Collection cleared but items remain alive during reinitialization
Usage Pattern:
// Save settings before reinit
var saved = Chart1.ViewModel.ChartObjectsCollection.Items
.Select(x => new { x.ItemName, x.LineWidth, x.Color }).ToList();
// Reinitialize
Chart1.SignalObservablesWithPoints = newData;
// Restore settings
foreach (var obj in Chart1.ViewModel.ChartObjectsCollection.Items)
{
var s = saved.FirstOrDefault(x => x.ItemName == obj.ItemName);
if (s != null) {
obj.LineWidth = s.LineWidth;
obj.Color = s.Color;
}
}
Examples
// Access settings
foreach (var obj in Chart1.ViewModel.ChartObjectsCollection.Items)
{
Console.WriteLine($"{obj.ItemName}: {obj.Color}");
obj.LineWidth = 5.0; // Modify settings
}