Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

WPF Charting using MVVM Pattern

, 19 Oct 2010 CPOL
Shows how to implement a WPF Chart in .NET 4.0 using MVVM Pattern
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using System.Windows.Controls.DataVisualization.Charting;
using System.Windows;
using System.Windows.Controls;

namespace WPFCharting.Commands
    class ShowSeries : ICommand
        public bool CanExecute(object parameter)
            return true;
        public void Execute(object parameter)
            string SelectedSeriesName = parameter as string;
            if (SelectedSeriesName == null) return;
            ContentControl TemporaryContentControl = null;
            switch (SelectedSeriesName)
                case "AreaSeries":
                    TemporaryContentControl = ucAreaSeries.getInstance();
                case "BarSeries" :
                    TemporaryContentControl = ucBarSeries.getInstance();
                case "BubbleSeries" :
                    TemporaryContentControl= ucBubbleSeries.getInstance();
                case "ColumnSeries":
                    TemporaryContentControl = ucColumnSeriesChart.getInstance();
                case "LineSeries":
                    TemporaryContentControl = ucLineSeries.getInstance();
                case "PieSeries":
                    TemporaryContentControl = ucPieSeriesChart.getInstance();
                case "ScatterSeries":
                    TemporaryContentControl = ucScatterSeries.getInstance();
            (MainWindowVM.getInstance()).MainChart = TemporaryContentControl;

        public event EventHandler CanExecuteChanged;

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.


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


About the Author

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

| Advertise | Privacy | Mobile
Web04 | 2.8.141022.2 | Last Updated 19 Oct 2010
Article Copyright 2010 by Mr. Javaman
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid