Click here to Skip to main content
15,879,535 members
Articles / Desktop Programming / WPF

How to create stock charts using the Silverlight Toolkit

Rate me:
Please Sign up or sign in to vote.
4.70/5 (15 votes)
16 Feb 2009CPOL2 min read 141.8K   2.7K   65  
An article on how to create a Candlestick stock chart using the Silverlight Toolkit.
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.ComponentModel;

namespace Microsoft.Windows.Controls.Samples
{
    /// <summary>
    /// The DataGridAutoCompleteBoxEdit class selects a small set of data to 
    /// display in the DataGrid. The XAML file contains the custom editing 
    /// template for AutoCompleteBox.
    /// </summary>
    [Sample("DataGrid Editing", DifficultyLevel.Advanced)]
    [Category("AutoCompleteBox")]
    public partial class DataGridAutoCompleteBoxEdit : UserControl
    {
        /// <summary>
        /// Initializes a new instance of the DataGridAutoCompleteBoxEdit type.
        /// </summary>
        public DataGridAutoCompleteBoxEdit()
        {
            InitializeComponent();
            Loaded += OnLoaded;
        }

        /// <summary>
        /// Handle the Loaded event of the page. This creates a small, random 
        /// set of data to display in the grid.
        /// </summary>
        /// <param name="sender">The source object.</param>
        /// <param name="e">The event arguments.</param>
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            List<RandomEmployeeDetails> data = new List<RandomEmployeeDetails>();
            Random random = new Random();

            // Select up to 8 random employees
            foreach (Employee employee in 
                new SampleEmployeeCollection()
                    .Where(item => random.Next(2) == 0)
                    .Distinct()
                    .Take(8))
            {
                data.Add(new RandomEmployeeDetails(employee));
            }
            MyDataGrid.ItemsSource = data;
        }
    }
}

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)


Written By
South Africa South Africa
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions