Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StocksView"/> class.
        /// </summary>
        public StocksView()
        {
            InitializeComponent();

            // Lets grab the data context
            _vm = DataContext as StockViewModel;
            if (_vm == null)
            {
                var error = new NullReferenceException("DataContext must be of type StockViewModel");
                DebugManager.LogError(error);
                throw error;
            }

            _vm.PropertyChanged += OnViewModelPropertyChanged;
            // If we have any saved information for last run, lets load it
            //_vm.Load();

            // Add some default data
            _vm.AddStockToWatchList(new List <string> {
                "ADBE", "MSFT", "INTC"
            });
            //_vm.AddStockToWatchList(new List<string> { "MSFT", });

            // get names of all axis scales
            var listAxisScales = new List <string>
            {
                AppStrings.Chart_AxisScale_Linear,
                AppStrings.Chart_AxisScale_Logarithmic
            };

            // bind axis scales to the chart's scale ComboBox
            this.ChartScaleComboBox.ItemsSource   = listAxisScales;
            this.ChartScaleComboBox.SelectedIndex = 0;

            // get names of all axis scales
            var listTrendlineTypes = new List <TrendLineType>
            {
                TrendLineType.None,
                TrendLineType.CubicFit,
                TrendLineType.CumulativeAverage,
                TrendLineType.ExponentialAverage,
                TrendLineType.ExponentialFit,
                TrendLineType.LinearFit,
                TrendLineType.LogarithmicFit,
                TrendLineType.ModifiedAverage,
                TrendLineType.PowerLawFit,
                TrendLineType.QuadraticFit,
                TrendLineType.QuarticFit,
                TrendLineType.QuinticFit,
                TrendLineType.SimpleAverage,
                TrendLineType.WeightedAverage
            };

            // bind trendline types to the chart's trendline ComboBox
            this.ChartTrendLineComboBox.ItemsSource   = listTrendlineTypes;
            this.ChartTrendLineComboBox.SelectedIndex = 0;

            // Select the First Stock
            //  _vm.SelectStockCommand.Execute("INTC");
            this.Loaded += OnNavigationPageLoaded;
        }