Share via

Command doesnt get callled

Rendy Putrayana 0 Reputation points
2025-02-08T04:52:43.71+00:00

im using communitytoolkit.maui behaviours to convert an event to a command, but it seems like the command in the viewmodel doesnt get called. ive set the binding context to the viewmodel. here is my code
<ContentPage.Behaviors>

<toolkit:EventToCommandBehavior EventName="Appearing"

                                Command="{Binding LoadBookmarksCommand}">

</toolkit:EventToCommandBehavior>

</ContentPage.Behaviors>

public partial class BookmarkViewModel : ObservableObject

{

public ObservableCollection<BookmarkProperty> BookmarksCollection { get; set; } =

    new ObservableCollection<BookmarkProperty>();

private BookmarkItemService bookmarkItemService = new BookmarkItemService();

void GetBookmarks()

{

    BookmarksCollection.Clear();

    var bookmarks = bookmarkItemService.ReadAll();

    foreach (var bookmark in bookmarks)

    {

        BookmarksCollection.Add(bookmark);

    }

}

[RelayCommand]

void LoadBookmarks()

{

    GetBookmarks();

}

}

Developer technologies | .NET | .NET Multi-platform App UI
Developer technologies | .NET | Other

1 answer

Sort by: Most helpful
  1. Rendy Putrayana 0 Reputation points
    2025-02-12T07:27:47.1566667+00:00

    thank you sir, ive downgrade the community.toolkit.maui to version 9.0.0 and its working perfectly fine.

    Was this answer 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.