Click here to Skip to main content
15,884,176 members
Articles / Mobile Apps / Windows Phone 7

XAMLFinance – A Cross-platform WPF, Silverlight & WP7 Application

Rate me:
Please Sign up or sign in to vote.
4.94/5 (99 votes)
21 Sep 2011CPOL27 min read 216.5K   9.9K   251  
This article describes the development of XAML Finance, a cross-platform application which works on the desktop, using Windows Presentation Foundation (WPF), on the web, using Silverlight and on Windows Phone 7 (WP7).
using System;
using System.Net;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using XAMLFinance.View;
using System.Collections.Generic;
using XAMLFinance.ViewModel.Command;

namespace XAMLFinance.ViewModel
{
    public partial class XAMLFinanceViewModel 
    {
        public static readonly string SelectedTabIndexProperty = "SelectedTabIndex";

        /// <summary>
        /// Field which backs the SelectedTab property
        /// </summary>
        private int _selectedTabIndex = -1;

        private ObservableCollection<ViewModelBase> _viewModels = new ObservableCollection<ViewModelBase>();

        public IEnumerable<ViewModelBase> ViewModels
        {
            get { return new ReadOnlyObservableCollection<ViewModelBase>(_viewModels); }
        }

        private ObservableCollection<ViewModelBase> _floatingViewModels = new ObservableCollection<ViewModelBase>();

        public IEnumerable<ViewModelBase> FloatingViewModels
        {
            get { return new ReadOnlyObservableCollection<ViewModelBase>(_floatingViewModels); }
        }

        /// <summary>
        /// Gets / sets the selected TabItem
        /// </summary>
        public int SelectedTabIndex
        {
            get { return _selectedTabIndex; }
            set
            {
                SetField(ref _selectedTabIndex, value, SelectedTabIndexProperty);
            }
        }


        public void AddViewModel(ViewModelBase viewModel)
        {
            viewModel.Init();
            _viewModels.Add(viewModel);
            SelectedTabIndex = _viewModels.Count - 1;
        }

        public void RemoveViewModel(ViewModelBase viewModel)
        {
            _viewModels.Remove(viewModel);
            _floatingViewModels.Remove(viewModel);
        }

        public void PopOutViewModel(ViewModelBase viewModel)
        {
            _viewModels.Remove(viewModel);
            _floatingViewModels.Add(viewModel);
        }

        public void PopInViewModel(ViewModelBase viewModel)
        {
            _floatingViewModels.Remove(viewModel);
            _viewModels.Add(viewModel);
            SelectedTabIndex = _viewModels.Count - 1;            
        }

        public ICommand ViewPriceListCommand
        {
          get
          {
            return new NavigateCommand(this, _pricelist);
          }
        }

        public ICommand ViewHeatMapCommand
        {
          get
          {
            return new NavigateCommand(this, _heatMap);
          }
        }

    }
}

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
Architect Scott Logic
United Kingdom United Kingdom
I am CTO at ShinobiControls, a team of iOS developers who are carefully crafting iOS charts, grids and controls for making your applications awesome.

I am a Technical Architect for Visiblox which have developed the world's fastest WPF / Silverlight and WP7 charts.

I am also a Technical Evangelist at Scott Logic, a provider of bespoke financial software and consultancy for the retail and investment banking, stockbroking, asset management and hedge fund communities.

Visit my blog - Colin Eberhardt's Adventures in .NET.

Follow me on Twitter - @ColinEberhardt

-

Comments and Discussions