Hello,
Welcome to our Microsoft Q&A platform!
I noticed that you display a dialog to create a new note and give it a title. If you want to navigate to the EditorPage
when you create or select a note, you can pass value(ID,model) like following code:
UpDate
NotesVM
CreateNewNoteCommand = new Command(async () => {
//you can use action to pass Id
EditorPage editorPage = new EditorPage();
await Application.Current.MainPage.Navigation.PushAsync(editorPage);
EditorVM Editor = (EditorVM)editorPage.BindingContext;
Editor.reciviceBookIdAction(RecivedNotebook.Id);
/*
//you can also use MessagingCenter to pass Id
await Application.Current.MainPage.Navigation.PushAsync(new EditorPage());
MessagingCenter.Send(this, "RecivedNotebookId", RecivedNotebook.Id);
*/
});
SelectedNoteCommand = new Command(async () => {
//you can use action to pass SelectedNote
EditorPage editorPage = new EditorPage();
await Application.Current.MainPage.Navigation.PushAsync(editorPage);
EditorVM Editor = (EditorVM)editorPage.BindingContext;
Editor.RecivedNoteAction(SelectedNote);
/*
//you can also use MessagingCenter to pass SelectedNote
await Application.Current.MainPage.Navigation.PushAsync(new EditorPage());
MessagingCenter.Send(this, "SelectedNote", SelectedNote);
*/
});
EditorPage(none)
/*
public EditorPage(String NotebookId)
{
InitializeComponent();
EditorVM Editor = (EditorVM)BindingContext;
Editor.CreateNote(NotebookId);
Console.WriteLine("{0}", NotebookId);
}
public EditorPage(Model.Note note)
{
InitializeComponent();
EditorVM Editor = (EditorVM)BindingContext;
Editor.RecivedNote = note;
Console.WriteLine("{0}", note.Id);
}
*/
EditorVM
public Action<string> reciviceBookIdAction; //use action
public Action<Note> RecivedNoteAction;
public EditorVM() {
SaveContent = new Command(() => { UpdateNote(); });
//use action(reciviceBookId)
reciviceBookIdAction = (reciviceBookId) =>
{
Console.WriteLine("reciviceBookId-----{0}", reciviceBookId);
//CreateNote(reciviceBookId);
};
/*
//use MessagingCenter(reciviceBookId)
MessagingCenter.Subscribe<NotesVM, string>(this, "RecivedNotebookId", (obj, item) => {
Console.WriteLine("reciviceBookId-----{0}", item);
});
*/
//use action(note)
RecivedNoteAction = (note) =>
{
RecivedNote = note;
Title = RecivedNote.Title;
Console.WriteLine("RecivedNote.id-----{0}", RecivedNote.Id);
};
/*
//use MessagingCenter(note)
MessagingCenter.Subscribe<NotesVM, Note>(this, "SelectedNote", (obj, item) => {
RecivedNote = item;
Title = RecivedNote.Title;
Console.WriteLine("RecivedNote.id-----{0}", item.Id);
});
*/
}
Best Regards,
Wenyan Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.