.NET MAUI – Forget Me Not – Part 5

Building on the previous blog posts, here I’d like to illustrate how you can pass complex data from one page’s view model to another’s.

Let’s assume we’ve tapped on the Buddies Icon on the tab bar and were taken to the BuddyList:

If we tap on one of our buddies, in this case, Rodrigo, we should be taken to the details page for that buddy. We could pass along the buddy’s id, or we can pass the buddy object itself.

To pass the entire Buddy object, we will create a dictionary that will contain an identifying text as the key, and the SelectedBuddy as the value,

var navigationParameter = new Dictionary<string, object>
{
    {"SelectedBuddy", SelectedBuddy}
};

We can now pass that along to the details page using Shell navigation.

await Shell.Current.GoToAsync($"buddydetail", navigationParameter);

“buddydetail” is the name you gave the BuddyDetails page in the constructor in AppShell.xaml.cs

public AppShell()
{
     InitializeComponent();

     Routing.RegisterRoute("buddydetail", typeof(BuddyDetail));

This routing matches the key “buddydetail” to the BuddyDetail page. Returning to the Shell navigation above, we see navigationParameter is the second param for the GoToAsync call. That is, we pass along the dictionary that contains our object. (We can pass as many objects as we like, each as an entry in the dictionary).

Receiving the data

In the view model for the details page, BuddyDetailViewModel, we use the QueryProperty attribute to indicate the name of the property to assign the passed-in object to and the key in the dictionary associated with that object.

Looking a few paragraphs up we can see that the dictionary has an entry with the key “SelectedBuddy” which has a value of the SelectedBuddy object. Here we are going to retrieve that into a local property, also named SelectedBuddy

[ObservableObject]
[QueryProperty(nameof(SelectedBuddy), "SelectedBuddy")]
public partial class BuddyDetailViewModel

Let me review that briefly as it can get confusing. There is the name of the local property: SelectedBuddy. There is the first parameter in the QueryProperty attribute: nameof(SelectedBuddy). These are 1:1 — the nameof is pointing to a property in this (receiving) class. Finally, there is the second param in the attribute, the string “SelectedBuddy” which is the key into the dictionary whose value will be assigned to the SelectedBuddy property. Right? Piece of pie.

We want to bind to a number of the properties of the buddy we just passed in. First, we’ll create those properties:

[ObservableProperty] private string name;
[ObservableProperty] private string emailAddress;
[ObservableProperty] private string code;
[ObservableProperty] private string? phoneNumber;
[ObservableProperty] private InvitationStatus status;
[ObservableProperty] private DateTime buddySince;
[ObservableProperty] private string buddySinceString;
[ObservableProperty] private string mailingAddressLine1;
[ObservableProperty] private string mailingAddressLine2;
[ObservableProperty] private int id;

Now all we need to do is set those properties using the object that was passed in and assigned to our SelectedBuddy property

 private Buddy selectedBuddy;
 public Buddy SelectedBuddy
 {
     get => selectedBuddy;
     set
     {
         SetProperty(ref selectedBuddy, value);
         Name = value.Name;
         EmailAddress = value.EmailAddress;
         PhoneNumber = value.PhoneNumber;
         Status = value.Status;
         BuddySince = value.BuddySince;
         BuddySinceString = BuddySince.ToString("D");
         MailingAddressLine1 = value.MailingAddressLine1;
         MailingAddressLine2 = value.MailingAddressLine2;
         Id = value.Id;
     }
 }

We can now display the details of the selected buddy using data binding. in the XAML.

Notice that there are two buttons: one to see the occasions you’ve asked to be reminded about, with regard to this buddy (e.g., the buddy’s birthday). The second button will display the buddy’s preferences. Each of these is made easier by using a service, in this case BuddyService. But how do we access the methods in BuddyService? This will be the topic of the next blog entry: Dependency Injection in MAUI.

Unknown's avatar

About Jesse Liberty

** Note ** Jesse is currently looking for a new position. You can learn more about him at https://jesseliberty.bio Thank you. Jesse Liberty has three decades of experience writing and delivering software projects and is the author of 2 dozen books and a couple dozen online courses. His latest book, Building APIs with .NET, is now available wherever you buy your books. Liberty was a Team Lead and Senior Software Engineer for various corporations, a Senior Technical Evangelist for Microsoft, a Distinguished Software Engineer for AT&T, a VP for Information Services for Citibank and a Software Architect for PBS. He is a 13 year Microsoft MVP.
This entry was posted in Essentials and tagged , , . Bookmark the permalink.

869 Responses to .NET MAUI – Forget Me Not – Part 5

  1. How to get cash for crypto in Rome

  2. best crypto cash out options in sweden

  3. USDT for cash without KYC Portugal

  4. Thomaszek's avatar Thomaszek says:

    Les devices Garmin offrent des outils avancées pour le sport .
    Équipées de GPS précis et de analyse de stress, ces montres s’adaptent à chaque niveaux.
    L’autonomie offre une longue durée selon le modèle, idéale pour usage quotidien.
    Garmin Vivoactive
    Les outils de suivi incluent les étapes et aussi les calories, aidant à optimal.
    Intuitives pour configurer , elles se synchronisent sans effort dans votre vie, grâce à des notifications ergonomique.
    Opter pour Garmin c’est profiter de une technologie fiable afin d’optimiser votre quotidien.

  5. Cómo vender criptomonedas en Buenos Aires

  6. crypto exchange istanbul with low fees

  7. Cambiar USDT por dólares en Buenos Aires

  8. safe p2p usdt exchange rates buenos aires

  9. over-the-counter usdt exchange barcelona

  10. binance's avatar binance says:

    Your article helped me a lot, is there any more related content? Thanks!

  11. Jerrymar's avatar Jerrymar says:

    Explore a wealth of fascinating and useful resources here .
    Whether you’re into in-depth guides to quick tips , you’ll find to suit all needs .
    Keep updated with fresh information built to educate plus entertain visitors.
    Our platform delivers an intuitive experience ensuring you can access tools right away.
    Become part of like-minded individuals and appreciate reliable content daily .
    Dive in now and access endless possibilities this platform delivers.
    https://zhez.info

  12. HarryDew's avatar HarryDew says:

    order ventolin from canada no prescription how much is ventolin AsthmaFree Pharmacy

  13. JefferyWitly's avatar JefferyWitly says:
  14. Arturofaips's avatar Arturofaips says:

    Das Rolex Cosmograph Daytona-Modell gilt als Ikone der Uhrmacherkunst, kombiniert sportliches Design mit technischer Perfektion durch das bewährte Automatikal movement.
    Verfügbar in Keramik-Editionen überzeugt die Uhr durch das ausgewogene Zifferblatt und hochwertige Materialien , die passionierte Sammler überzeugen.
    Dank einer Batterie von bis zu drei Tagen eignet sie sich für sportliche Herausforderungen und behält stets ihre Genauigkeit unter jeder Bedingung .
    Rolex Daytona 116508 herrenuhren
    Die ikonischen Unterzifferblätter mit Perlmutt-Einsätzen betonen den luxuriösen Touch, während die kratzfeste Saphirglase Langlebigkeit garantieren .
    Seit ihrer Einführung 1963 bleibt sie ein Maßstab der Branche, geschätzt für ihre Seltenheit bei Investoren weltweit.
    Ob im Rennsport inspiriert – die Cosmograph Daytona verbindet Tradition und etabliert sich als unverwechselbares Statement für anspruchsvolle Träger .

  15. Benniehycle's avatar Benniehycle says:

    Bold metallic fabrics dominate 2025’s fashion landscape, blending futuristic elegance with sustainable innovation for everyday wearable art.
    Unisex tailoring challenge fashion norms, featuring asymmetrical cuts that transform with movement across formal occasions.
    Algorithm-generated prints merge digital artistry , creating hypnotic color gradients that react to body heat for dynamic visual storytelling .
    https://friendza.enroles.com/read-blog/36468
    Zero-waste construction lead the industry , with upcycled materials reducing environmental impact without compromising luxurious finishes .
    Light-refracting details add futuristic flair, from nano-embroidered handbags to 3D-printed footwear designed for modern practicality .
    Vintage revival meets techwear defines the year, as 90s grunge textures reinterpret archives through smart fabric technology for timeless relevance .

  16. Larrybocky's avatar Larrybocky says:

    order corticosteroids without prescription: Relief Meds USA – anti-inflammatory steroids online

  17. Jamesexape's avatar Jamesexape says:

    where buy cheap clomid without dr prescription Clomid Hub clomid cheap

  18. BrianBog's avatar BrianBog says:

    NeuroRelief Rx: NeuroRelief Rx – NeuroRelief Rx

  19. Ralphnup's avatar Ralphnup says:

    NeuroRelief Rx: NeuroRelief Rx – gabapentin neurontin action

  20. Larrybocky's avatar Larrybocky says:

    Relief Meds USA: order corticosteroids without prescription – ReliefMeds USA

  21. Miguelfub's avatar Miguelfub says:

    Greetings, passionate guardians of holistic well-being! I once got trapped in the glittering guise of speedy symptom suppressors, trusting them unconditionally whenever wellness warnings echoed. However, vital insights burst through, demonstrating these fleeting aids endangered long-term health, fueling a passionate pursuit for the foundations of enduring physical strength. It invigorated my entire being, validating how wise, health-empowering practices enhance our innate health defenses and glow, rather than jeopardizing our health equilibrium.
    In the heart of a health crisis, I rejected outdated health norms, uncovering advanced strategies for optimal health that fuse restorative habits with cutting-edge preventive medicine. Prepare for the vitality-vaulting core: cenforce sildenafil, where on the iMedix podcast we explore its profound impacts on health with transformative tips that’ll inspire you to tune in now and revitalize your life. The health surge redefined my path: vitality thrives in balanced health synergy, while reckless health shortcuts compromise immunity. Today, I’m energized by this health mission to captivate you with these vital health breakthroughs, positioning treatments as allies in health mastery.
    Probing the core of wellness dynamics, I grasped the essential truth that health interventions must nurture and fortify, not at the expense of natural health balance. It’s a narrative rich in transformative health growth, inspiring you to upgrade suboptimal health dependencies for superior immune and emotional health. And the health hook that pulls you deeper: balance.

  22. Jamesexape's avatar Jamesexape says:

    prednisone daily use prednisone 2 5 mg ReliefMeds USA

  23. Can you be more specific about the content of your article? After reading it, I still have some doubts. Hope you can help me.

  24. Thank you for your articles. I find them very helpful. Could you help me with something? http://www.hairstylesvip.com

  25. Ralphnup's avatar Ralphnup says:

    where to buy Modafinil legally in the US: wakefulness medication online no Rx – Wake Meds RX

  26. BrianBog's avatar BrianBog says:

    NeuroRelief Rx: can i cut gabapentin in half – gabapentin 100mg high

  27. Larrybocky's avatar Larrybocky says:

    buy prednisone from canada: ReliefMeds USA – prednisone 10mg tablet cost

  28. Patrickatopy's avatar Patrickatopy says:

    https://neuroreliefrx.com/# gabapentin depletes nutrients

  29. Jamesexape's avatar Jamesexape says:

    safe Provigil online delivery service Wake Meds RX Modafinil for focus and productivity

  30. Ralphnup's avatar Ralphnup says:

    does gabapentin cause kidney problems: safe way to come off gabapentin – NeuroRelief Rx

  31. BrianBog's avatar BrianBog says:

    prednisone 20mg online pharmacy: prednisone online india – Relief Meds USA

  32. Larrybocky's avatar Larrybocky says:

    ReliefMeds USA: prednisone 5mg coupon – ReliefMeds USA

  33. Jamesexape's avatar Jamesexape says:

    WakeMeds RX where to buy Modafinil legally in the US affordable Modafinil for cognitive enhancement

  34. Robertmup's avatar Robertmup says:

    Татуировки — это уникальное искусство , где каждый элемент несёт личную историю и отражает характер человека.
    Для многих тату — вечный символ , который напоминает о преодолённых трудностях и становится частью пути .
    Сам акт нанесения — это творческий диалог между мастером и клиентом , где тело становится живым холстом .
    иглы для тату
    Разные направления, от акварельных рисунков до биомеханических композиций, позволяют воплотить самую смелую фантазию в изысканной форме .
    Красота тату в способности расти вместе с человеком, превращая эмоции в незабываемый визуальный язык .
    Выбирая узор , люди показывают своё «я» через формы, создавая личное произведение, которое наполняет уверенностью каждый день.

Comments are closed.