DevExpress v24.2 Update — Your Feedback Matters
Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.
Take the survey
Not interested
ConstantLine.LegendMarkerTemplate Property
Namespace : DevExpress.Xpf.Charts
Assembly :
DevExpress.Xpf.Charts.v24.2.dll
NuGet Package :
DevExpress.Wpf.Charts
# Declaration
# Property Value
# Example
This example shows how to apply the LegendMarkerTemplate property to change a constant line ‘s marker at design time and runtime.
Use the following API members to create and customize a constant line:
<Window x:Class ="WpfApplication14.MainWindow"
xmlns ="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x ="http://schemas.microsoft.com/winfx/2006/xaml"
Title ="MainWindow" Height ="350" Width ="525"
xmlns:dxc ="http://schemas.devexpress.com/winfx/2008/xaml/charts" >
<Grid >
<dxc:ChartControl Name ="chartControl1" >
<dxc:ChartControl.Resources >
<DataTemplate x:Key ="LegendMarkerTemplate" >
<Border BorderThickness ="1"
BorderBrush ="{Binding Path=MarkerLineBrush}" >
<Path x:Name = "MarkerPath"
Stretch ="Fill"
Fill ="{Binding Path=MarkerBrush}"
Stroke ="{Binding Path=MarkerLineBrush}"
StrokeThickness ="{Binding Path=MarkerLineStyle.Thickness}"
StrokeDashArray ="{Binding Path=MarkerLineStyle.DashStyle.Dashes}"
StrokeDashOffset ="{Binding Path=MarkerLineStyle.DashStyle.Offset}"
StrokeDashCap ="{Binding Path=MarkerLineStyle.DashCap}"
StrokeLineJoin ="{Binding Path=MarkerLineStyle.LineJoin}"
StrokeMiterLimit ="{Binding Path=MarkerLineStyle.MiterLimit}"
SnapsToDevicePixels ="True"
StrokeStartLineCap ="Square"
StrokeEndLineCap ="Square" >
<Path.Data >
<LineGeometry StartPoint ="0,0" EndPoint ="10,0" />
</Path.Data >
</Path >
</Border >
</DataTemplate >
</dxc:ChartControl.Resources >
<dxc:ChartControl.Legends >
<dxc:Legend />
</dxc:ChartControl.Legends >
<dxc:ChartControl.Diagram >
<dxc:XYDiagram2D >
<dxc:XYDiagram2D.AxisY >
<dxc:AxisY2D >
<dxc:AxisY2D.ConstantLinesInFront >
<dxc:ConstantLine Value ="0.5" Brush ="Green"
LegendText ="Design time CL"
LegendMarkerTemplate ="{StaticResource LegendMarkerTemplate}" >
<dxc:ConstantLine.LineStyle >
<dxc:LineStyle Thickness ="2" >
<dxc:LineStyle.DashStyle >
<DashStyle Dashes ="2 2" />
</dxc:LineStyle.DashStyle >
</dxc:LineStyle >
</dxc:ConstantLine.LineStyle >
</dxc:ConstantLine >
</dxc:AxisY2D.ConstantLinesInFront >
</dxc:AxisY2D >
</dxc:XYDiagram2D.AxisY >
<dxc:XYDiagram2D.Series >
<dxc:LineSeries2D DisplayName ="Series"
MarkerVisible ="True"
ShowInLegend ="False" >
<dxc:LineSeries2D.Points >
<dxc:SeriesPoint Argument ="A" Value ="3" />
<dxc:SeriesPoint Argument ="B" Value ="2" />
<dxc:SeriesPoint Argument ="C" Value ="3" />
<dxc:SeriesPoint Argument ="D" Value ="5" />
</dxc:LineSeries2D.Points >
</dxc:LineSeries2D >
</dxc:XYDiagram2D.Series >
</dxc:XYDiagram2D >
</dxc:ChartControl.Diagram >
</dxc:ChartControl >
</Grid >
</Window >
using DevExpress.Xpf.Charts ;
using System.Windows ;
namespace WpfApplication14 {
public partial class MainWindow : Window {
public MainWindow ( ) {
InitializeComponent();
XYDiagram2D diagram = ((XYDiagram2D)chartControl1.Diagram);
diagram.ActualAxisY.ConstantLinesBehind.Add(
new ConstantLine() {
Value = 4.5 ,
LegendText = "Runtime CL" ,
LegendMarkerTemplate = chartControl1.FindResource("LegendMarkerTemplate" ) as DataTemplate
});
}
}
}
Imports DevExpress.Xpf.Charts
Imports System.Windows
Namespace WpfApplication14
Partial Public Class MainWindow
Inherits Window
Public Sub New ()
InitializeComponent()
Dim diagram As XYDiagram2D = (CType (chartControl1.Diagram, XYDiagram2D))
diagram.ActualAxisY.ConstantLinesBehind.Add(New ConstantLine() With {
.Value = 4.5 ,
.LegendText = "Runtime CL" ,
.LegendMarkerTemplate = TryCast (chartControl1.FindResource("LegendMarkerTemplate" ), DataTemplate)
})
End Sub
End Class
End Namespace
See Also