|
using System.Windows;
using System.Collections.Generic;
using System.Windows.Input;
using System.Windows.Data;
using System.ComponentModel;
using RowHeaderGrid.Models;
using RowHeaderGrid.Commands;
using RowHeaderGrid.Views;
using RowHeaderGrid.Utils;
using RowHeaderGrid.DataAccess;
using System.Collections.ObjectModel;
using Microsoft.Windows.Controls;
namespace RowHeaderGrid.ViewModels
{
public class MainViewModel : ViewModelBase
{
private DelegateCommand exitCommand;
public DelegateCommand<DataGridItem> CellClickCommand { get; private set; }
IList<Item> _items;
public IList<Item> Items
{
get { return _items; }
set
{
_items = value;
base.OnPropertyChanged("Items");
}
}
#region Constructor
public MainViewModel()
{
_items = DataAccess.DataAccess.LoadItems();
CellClickCommand = new DelegateCommand<DataGridItem>(CellClickSelection, CanCellClickSelection);
}
#endregion
public ICommand ExitCommand
{
get
{
if (exitCommand == null)
{
exitCommand = new DelegateCommand(Exit);
}
return exitCommand;
}
}
private void Exit()
{
Application.Current.Shutdown();
}
private void CellClickSelection(DataGridItem item)
{
MessageBox.Show("Cell's column is " + item.Gridcell.Column.Header.ToString() +
" it's ID is " + ((RowHeaderGrid.Models.Item)(item.Gridrow.Item)).ID);
}
private bool CanCellClickSelection(DataGridItem cell)
{
return true;
}
}
}
|
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.