BindableApplicationBar.ViewModel.MainViewModel.MainViewModel C# (CSharp) Method

MainViewModel() public method

public MainViewModel ( IMessageBoxService messageBoxService ) : System
messageBoxService IMessageBoxService
return System
        public MainViewModel(IMessageBoxService messageBoxService)
        {
            _messageBoxService = messageBoxService;

            AddItemCommand = new RelayCommand(() =>
            {
                Items.Add(DateTime.Now.ToString());

                EnableSelectionCommand.RaiseCanExecuteChanged();
            });

            EnableSelectionCommand = new RelayCommand(() =>
            {
                IsSelectionEnabled = true;
            }, () => Items.Count > 0);

            DeleteItemsCommand = new RelayCommand<System.Collections.IList>(items =>
            {
                var itemsToRemove = items
                    .Cast<string>()
                    .ToArray();

                foreach (var itemToRemove in itemsToRemove)
                {
                    Items.Remove(itemToRemove);
                }

                EnableSelectionCommand.RaiseCanExecuteChanged();

                IsSelectionEnabled = false;
            });

            BackKeyPressCommand = new RelayCommand<CancelEventArgs>(e =>
            {
                if (IsSelectionEnabled)
                {
                    IsSelectionEnabled = false;

                    e.Cancel = true;
                }
            });

            AboutCommand = new RelayCommand(() =>
            {
                _messageBoxService.Show("Cimbalino Windows Phone Toolkit Bindable Application Bar Sample", "About");
            });

            Items = new ObservableCollection<string>();
        }
MainViewModel