public ReferenceList(ReferenceListViewModel vm) { InitializeComponent(); // 1. Initialize commands vm.OpenReferenceCommand = new RelayCommand(OpenReference); }
/** * Command actions: * - Open bookmark * [The actual command is in viewmodel] */ public void OpenReference(object input) { ReferenceListViewModel vm = (ReferenceListViewModel)this.DataContext; Reference sent_reference = input as Reference; Page _referenceView = new ReferenceView(); _referenceView.DataContext = new ReferenceViewViewModel(sent_reference, vm.User, vm.WorkStatus, new DialogService()); NavigationService.Navigate(_referenceView); }
// Constructor public ReferenceEditorViewModel(Reference reference, ReferenceListViewModel parent, IDialogService dialogService) { this.Title = "Save as..."; this._dialogService = dialogService; this.Reference = new Reference(); this.Reference.CopyByValue(reference); this._parent = parent; if (Reference.ArticleID != 0 && Reference.ArticleID != null) { this.MainArticleTitle = (new ArticleRepo()).GetArticleWithId(Reference.ArticleID).Title; } SaveReferenceCommand = new RelayCommand(SaveReference, CanSaveReference); }
public Bookmarks() { InitializeComponent(); this.Loaded += (object sender, RoutedEventArgs e) => { if (this.DataContext is BookmarksViewModel) { BookmarksViewModel vm = (BookmarksViewModel)this.DataContext; BookmarkListViewModel view_model = new BookmarkListViewModel(vm.User, vm.WorkStatus, new DialogService(), new WindowService()); Page _mainPage = new BookmarkList(view_model); _mainPage.DataContext = view_model; _mainFrame.Navigate(_mainPage); } else if (this.DataContext is ReferencesViewModel) { ReferencesViewModel vm = (ReferencesViewModel)this.DataContext; ReferenceListViewModel view_model = new ReferenceListViewModel(vm.User, vm.WorkStatus, new DialogService(), new WindowService()); Page _mainPage = new ReferenceList(view_model); _mainPage.DataContext = view_model; _mainFrame.Navigate(_mainPage); } }; }