Skip to main content

How to: Assign Different Models for Series and Point Markers

This example demonstrates how to specify different models for all series.

To accomplish this, define models in your Window’s Resources and then assign them to the appropriate series via their Model property.

<Window x:Class="PredefinedModels.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" >
    <!--region #Series and marker models.-->
    <Window.Resources>
        <ResourceDictionary>
            <dxc:CrossMarker2DModel x:Key="areaModel" />
            <dxc:FlatBar2DModel x:Key="barModel" />
            <dxc:CircleMarker2DModel x:Key="lineModel" />
        </ResourceDictionary>
    </Window.Resources>
    <!--endregion #Series and marker models.-->

    <Grid>
        <dxc:ChartControl Name="chartControl1" >
            <dxc:ChartControl.Diagram>
                <dxc:XYDiagram2D>
                    <dxc:XYDiagram2D.Series>
                        <!--region #Area Series.-->
                        <dxc:AreaSeries2D MarkerVisible="True" DisplayName="Area Series" MarkerModel="{StaticResource areaModel}">
                            <dxc:AreaSeries2D.Label>
                                <dxc:SeriesLabel Visible="False"/>
                            </dxc:AreaSeries2D.Label>
                            <dxc:AreaSeries2D.Points>
                                <dxc:SeriesPoint Argument="A" Value="4" />
                                <dxc:SeriesPoint Argument="B" Value="2" />
                                <dxc:SeriesPoint Argument="C" Value="3" />
                                <dxc:SeriesPoint Argument="D" Value="2" />
                            </dxc:AreaSeries2D.Points>
                        </dxc:AreaSeries2D>
                        <!--endregion #Area Series.-->
                        <!--region #Bar Series.-->
                        <dxc:BarSideBySideSeries2D  DisplayName="Bar Series" Model="{StaticResource barModel}">
                            <dxc:BarSideBySideSeries2D.Label>
                                <dxc:SeriesLabel Visible="False"/>
                            </dxc:BarSideBySideSeries2D.Label>
                            <dxc:BarSideBySideSeries2D.Points>
                                <dxc:SeriesPoint Argument="A" Value="4" />
                                <dxc:SeriesPoint Argument="B" Value="3" />
                                <dxc:SeriesPoint Argument="C" Value="2" />
                                <dxc:SeriesPoint Argument="D" Value="1" />
                            </dxc:BarSideBySideSeries2D.Points>
                        </dxc:BarSideBySideSeries2D>
                        <!--endregion #Bar Series.-->
                        <!--region #Line Series.-->
                        <dxc:LineSeries2D MarkerVisible="True" DisplayName="Line Series" MarkerModel="{StaticResource lineModel}">
                            <dxc:LineSeries2D.Label>
                                <dxc:SeriesLabel Visible="False"/>
                            </dxc:LineSeries2D.Label>
                            <dxc:LineSeries2D.Points>
                                <dxc:SeriesPoint Argument="A" Value="1" />
                                <dxc:SeriesPoint Argument="B" Value="2" />
                                <dxc:SeriesPoint Argument="C" Value="1" />
                                <dxc:SeriesPoint Argument="D" Value="3" />
                            </dxc:LineSeries2D.Points>
                        </dxc:LineSeries2D>
                        <!--endregion #Line Series.-->
                    </dxc:XYDiagram2D.Series>
                </dxc:XYDiagram2D>
            </dxc:ChartControl.Diagram>
            <dxc:ChartControl.Legend>
                <dxc:Legend Visibility="Visible" />
            </dxc:ChartControl.Legend>
        </dxc:ChartControl>
    </Grid>
</Window>