Ideablade Cocktail for Windows Store – Part 2

A Cocktail project is usually grouped into folders called Views and ViewModels. The Views folder contains all the XAML files, and the ViewModels contain the datacontext that each view binds against.

We’ll create the missing GroupedItemsPageViewModel first, and then drag them into the Views and ViewModels folder. All Cocktail ViewModels that represent a screen should inherit from Screen, and INavigationTarget. The INavigationTarget has two purposes:

  1. It provides notification when a screen has been navigated to, or navigating away from – Similar to Silverlights Navigation events
  2. It also provides notification that the screen is about to go into suspended state, so that we can save the work and resume later.
using Caliburn.Micro;
using Cocktail;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AssignmentTracker
    public class GroupedItemsPageViewModel : Screen, INavigationTarget
        private INavigator _navigator;

        public GroupedItemsPageViewModel(INavigator navigator)
            _navigator = navigator;

        #region INavigationTarget

        public void LoadState(object navigationParameter, Dictionary<string, object> pageState, Dictionary<string, object> sharedState) { }

        public void OnNavigatedFrom(NavigationArgs args) { }

        public void OnNavigatedTo(NavigationArgs args) { }

        public void OnNavigatingFrom(NavigationCancelArgs args) { }

        public string PageKey { get; set; }

        public void SaveState(Dictionary<string, object> pageState, Dictionary<string, object> sharedState) { }


So far, we have not loaded any entity from the database yet. That’ll be the next topic.

Next: Querying entities