xamarin-docs icon indicating copy to clipboard operation
xamarin-docs copied to clipboard

Code typo

Open GerardFR opened this issue 2 years ago • 0 comments

[Enter feedback here] In the Data Binding section, the LoadNote code is placed within the ItemId property, which is obviously wrong. The code should be:

    public string ItemId
    {
        set
        {
            LoadNote(value);
        }
    }

    async void LoadNote(string itemId)
    {
        try
        {
            int id = Convert.ToInt32(itemId);
            // Retrieve the note and set it as the BindingContext of the page.
            Note note = await App.Database.GetNoteAsync(id);
            BindingContext = note;
        }
        catch (Exception)
        {
            Console.WriteLine("Failed to load note.");
        }
    }

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

GerardFR avatar Jul 24 '21 08:07 GerardFR