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
CustomBar2DModel Class
Namespace : DevExpress.Xpf.Charts
Assembly :
DevExpress.Xpf.Charts.v24.2.dll
NuGet Package :
DevExpress.Wpf.Charts
# Declaration
To provide a custom 2D Bar model, create an instance of the CustomBar2DModel class, and assign it to the BarSeries2D.Model property.
To apply a pre-defined 2D Bar model in your chart, use the corresponding descendant of the PredefinedBar2DModel class.
# Example
This example illustrates how to create custom bar models.
To do this, create an object that represents a custom model of a particular series (CustomBar2DModel
) and assign it to the Model property of a corresponding series type (BarSeries2D.Model ).
Then, create the ControlTemplate object which contains all necessary visual elements to create your own custom model. Assign this template to the PointTemplate property of a series custom model (CustomBar2DModel.PointTemplate ).
<Window x:Class ="CustomBarModels.MainWindow"
xmlns ="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x ="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dxc ="http://schemas.devexpress.com/winfx/2008/xaml/charts"
Title ="MainWindow" Height ="350" Width ="525" >
<Window.Resources >
<ResourceDictionary >
<dxc:BrushOverlayConverter x:Key ="brushOverlayConverter" />
</ResourceDictionary >
</Window.Resources >
<Grid >
<dxc:ChartControl >
<dxc:ChartControl.Diagram >
<dxc:XYDiagram2D >
<dxc:XYDiagram2D.Series >
<dxc:BarSideBySideSeries2D ColorEach ="True" >
<dxc:BarSideBySideSeries2D.Model >
<dxc:CustomBar2DModel >
<dxc:CustomBar2DModel.PointTemplate >
<ControlTemplate >
<Grid >
<Border x:Name ="border" Background ="{Binding Path=PointColor, ConverterParameter=Gray, Converter={StaticResource brushOverlayConverter}}"
Opacity ="0.25" CornerRadius ="5,5,0,0" Margin ="0,-4,0,0" RenderTransformOrigin ="0.5,0.5" >
<Border.RenderTransform >
<ScaleTransform />
</Border.RenderTransform >
</Border >
<Border Background ="{Binding Path=PointColor, ConverterParameter=Gray, Converter={StaticResource brushOverlayConverter}}"
CornerRadius ="3,3,0,0" Margin ="4,0,4,0" >
<Border CornerRadius ="2,2,0,0" Margin ="1,1,1,0" >
<Border.Background >
<Binding Path ="PointColor" Converter ="{StaticResource brushOverlayConverter}" >
<Binding.ConverterParameter >
<LinearGradientBrush EndPoint ="0,0.5" StartPoint ="1,0.5" >
<GradientStop Color ="#FFB2B2B2" Offset ="0" />
<GradientStop Color ="#FFC2C2C2" Offset ="1" />
</LinearGradientBrush >
</Binding.ConverterParameter >
</Binding >
</Border.Background >
</Border >
</Border >
</Grid >
</ControlTemplate >
</dxc:CustomBar2DModel.PointTemplate >
</dxc:CustomBar2DModel >
</dxc:BarSideBySideSeries2D.Model >
<dxc:BarSideBySideSeries2D.Points >
<dxc:SeriesPoint Argument ="A" Value ="2.3" />
<dxc:SeriesPoint Argument ="B" Value ="3.2" />
<dxc:SeriesPoint Argument ="C" Value ="2.8" />
<dxc:SeriesPoint Argument ="D" Value ="2.6" />
<dxc:SeriesPoint Argument ="E" Value ="3.3" />
<dxc:SeriesPoint Argument ="F" Value ="4.2" />
<dxc:SeriesPoint Argument ="G" Value ="3.9" />
<dxc:SeriesPoint Argument ="H" Value ="4.6" />
</dxc:BarSideBySideSeries2D.Points >
</dxc:BarSideBySideSeries2D >
</dxc:XYDiagram2D.Series >
</dxc:XYDiagram2D >
</dxc:ChartControl.Diagram >
</dxc:ChartControl >
</Grid >
</Window >
See Also