ChartControl.AnnotationItemsSource Property
Gets or sets the collection of objects used to generate annotations.
Namespace: DevExpress.Xpf.Charts
Assembly: DevExpress.Xpf.Charts.v24.2.dll
NuGet Package: DevExpress.Wpf.Charts
#Declaration
public IEnumerable AnnotationItemsSource { get; set; }
#Property Value
Type | Description |
---|---|
IEnumerable | A collection that is used to generate annotations. The default is null (Nothing in Visual Basic). |
#Example
The Chart Control can generate its child elements from their ViewModels. This is useful when the application uses the MVVM architecture and the Chart should contain several chart elements that are bound to data. Use the ChartControl.AnnotationItemsSource
property to specify the collection the Chart control utilizes to generate annotations. The ChartControl.AnnotationItemTemplate property allows you to define annotation presentation.
Note
If you have more than one template that can be used to render annotations, you can implement custom logic to choose the required template. To do this, derive from the Data
public class ChartViewModel {
public IEnumerable<MyAnnotation> Annotations { get; private set; }
public ChartViewModel() {
Annotations = new Collection<MyAnnotation> {
new MyAnnotation("Annotation 1", 2012, 6.203) {
ConnectorLength = 100,
Angle = -45
},
new MyAnnotation("Annotation 2", 2010, 5.7) {
ConnectorLength = 100,
Angle = 0
}
};
}
public class MyAnnotation {
public string Content { get; set; }
public AxisXCoordinate XValue { get; set; }
public AxisYCoordinate YValue { get; set; }
public double ConnectorLength { get; set; }
public double Angle { get; set; }
public MyAnnotation(string content, double xVal, double yVal) {
Content = content;
XValue = new AxisXCoordinate() { AxisValue = xVal };
YValue = new AxisYCoordinate() { AxisValue = yVal };
}
}
}