AxisLabelItem.SourceObject Property
The object that is used to generate the axis label.
Namespace: DevExpress.Xpf.Charts
Assembly: DevExpress.Xpf.Charts.v24.2.dll
NuGet Package: DevExpress.Wpf.Charts
Declaration
Property Value
Type | Description |
---|---|
Object | A business object that stores information required to create an axis label. |
Remarks
The following example generates custom axis labels for a y-axis from a View Model:
<Window.DataContext>
<viewModel:ChartViewModel/>
</Window.DataContext>
<dxc:ChartControl>
<dxc:XYDiagram2D>
<dxc:XYDiagram2D.AxisY>
<dxc:AxisY2D CustomLabelItemsSource="{Binding CustomLabels}">
<dxc:AxisY2D.CustomLabelItemTemplate>
<DataTemplate>
<dxc:CustomAxisLabel Value="{Binding AxisValue}">
<dxc:CustomAxisLabel.Content>
<TextBlock FontSize="20"
Foreground="Green"
Text="{Binding SourceObject.LabelContent}">
</TextBlock>
</dxc:CustomAxisLabel.Content>
</dxc:CustomAxisLabel>
</DataTemplate>
</dxc:AxisY2D.CustomLabelItemTemplate>
</dxc:AxisY2D>
</dxc:XYDiagram2D.AxisY>
<!--...-->
</dxc:XYDiagram2D>
</dxc:ChartControl>
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace DXSample
{
public class ChartViewModel
{
public ObservableCollection<LabelItem> CustomLabels { get; set; }
public ChartViewModel()
{
CustomLabels = new ObservableCollection<LabelItem>();
CustomLabels.Add(new LabelItem() { AxisValue = 5, LabelContent = "5++" });
CustomLabels.Add(new LabelItem() { AxisValue = 10, LabelContent = "10++"});
CustomLabels.Add(new LabelItem() { AxisValue = 15, LabelContent = "15**" });
}
}
public class LabelItem
{
public double AxisValue { get; set; }
public string LabelContent { get; set; }
}
}
See Also