Click here to Skip to main content
14,488,855 members

WPF Charting using MVVM Pattern

Rate this:
4.95 (15 votes)
Please Sign up or sign in to vote.
4.95 (15 votes)
19 Oct 2010CPOL
Shows how to implement a WPF Chart in .NET 4.0 using MVVM Pattern
<UserControl x:Class="WPFCharting.ucScatterSeries"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:chartingToolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <chartingToolkit:Chart
            x:Name="Chart1"
            VerticalAlignment="Stretch"             
            HorizontalAlignment="Stretch" 
            Margin="5,0,0,0"            
            Title="{Binding Path=Title}"
            LegendTitle="{Binding   Path=LegendTitle}">
            <chartingToolkit:ScatterSeries
                x:Name="XScatterSeries"
                 DataContext="{Binding}"
                DependentValueBinding="{Binding Path=Value}"                 
                IndependentValueBinding="{Binding Path=Key}" 
                ItemsSource="{Binding Path=data}"
             />
        </chartingToolkit:Chart>
    </Grid>
</UserControl>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Mr. Angular
Software Developer (Senior)
United States United States
Mr Javaman

Comments and Discussions

Tagged as

Stats

306.8K views
5.1K downloads
70 bookmarked