Click here to Skip to main content
13,553,830 members
Click here to Skip to main content

Tagged as

Stats

291.6K views
4.8K downloads
68 bookmarked
Posted 14 Oct 2010
Licenced CPOL

WPF Charting using MVVM Pattern

, 19 Oct 2010
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();
                    break;
                case "BarSeries" :
                    TemporaryContentControl = ucBarSeries.getInstance();
                    break;
                case "BubbleSeries" :
                    TemporaryContentControl= ucBubbleSeries.getInstance();
                    break;
                case "ColumnSeries":
                    TemporaryContentControl = ucColumnSeriesChart.getInstance();
                    break;
                case "LineSeries":
                    TemporaryContentControl = ucLineSeries.getInstance();
                    break;
                case "PieSeries":
                    TemporaryContentControl = ucPieSeriesChart.getInstance();
                    break;
                case "ScatterSeries":
                    TemporaryContentControl = ucScatterSeries.getInstance();
                    break;
                default:
                    break;
            }
            (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.

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. Javaman
Software Developer (Senior)
United States United States
Mr Javaman

You may also be interested in...

Pro
Pro
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02-2016 | 2.8.180515.1 | Last Updated 19 Oct 2010
Article Copyright 2010 by Mr. Javaman
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid