private void SetDataContext() { try { Shortcuts shortcuts = null; if (IsFirstTimeRun()) { // This is the first time the application is runing. shortcuts = NewData.NewShortcuts(); SaveData.SaveShortcuts(shortcuts, true); } else { // This is not the first time the application is runing. // Get the shortcuts data shortcuts = ShortcutsData.GetShortcuts(); // If shortcuts is null then perhaps the sortcut data file is corrupted. if (shortcuts == null) { MessageBoxResult messageBoxResult = MessageBox.Show("For some reason shortcuts are corrupted.\nReseting shortcuts.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); shortcuts = NewData.NewShortcuts(); SaveData.SaveShortcuts(shortcuts, true); } } DataContext = ContextHelper.ShortcutsToVM(shortcuts); } catch (Exception ex) { Error.ShowDialog(ex); } }