Share via

help with filering

Eduardo Gomez 4,316 Reputation points
2022-01-28T03:00:24.813+00:00

Hello

I have a weird issue, I am filtering my notebooks in the firebasService class, and that is working fine and I can see it in my collectionView

But when I click a notebook, I supposedly filter with this code

   public async void ReadAsync(string ChildName, string NotebookId = "") {

            var list = await Client.Child(ChildName)
                 .OnceAsync<NotebookNote>();

            var collection = new List<NotebookNote>();

            foreach (var item in list) {
                NotebookNote notebookNote = null;
                notebookNote = Convert(ChildName, item);
                collection.Add(notebookNote);
            }

            if (ChildName.Equals(App.Notes)) {
                collection.Where(n => ((Note)n).NotebookId == NotebookId).ToList();
            } else {
                collection = collection.Where(n => n.UserID == Preferences.Get(App.UserID, string.Empty)).ToList();
            }
            FireBaseNotebooks.Clear();
            foreach (var element in collection) {
                FireBaseNotebooks.Add(element);
            }

As you can see I check if the child name is a note, and I also send the Notebook as a parameter because the query is bring me all the notes from the notebook that has this specific id

https://github.com/eduardoagr/DuoNotes

Developer technologies | .NET | Xamarin

Answer accepted by question author

Cole Xia (Shanghai Wicresoft Co,.Ltd.) 6,756 Reputation points
2022-01-31T06:59:45.197+00:00

Hello,

Welcome to our Microsoft Q&A platform!

You're getting RecivedSelectedNotebook as null in constructor because

It is populated with value in RecivedSelectedNotebookAccion , RecivedSelectedNotebookAccion is an Action , here it is used as a callback , it is only triggered when clicking on the specific note , but before you clicking on it , the viewmodel has already finished its initialization .

Refer to

https://stackoverflow.com/a/22024979/8187800.

Best Regards,

Cole Xia


If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

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.

Was this answer helpful?


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.