SfNavigationDrawer not working with CommunityToolkit.Mvvm

Hy Syncfusion Team,

I use for a project the SfNavigationDrawer and set a ContentPage like suggested in this article:

https://support.syncfusion.com/kb/article/15674/how-to-load-content-page-to-net-maui-navigationdrawer-contentview

But in the page set as ContentView of the SfNavigationDrawer the CommunityToolkit.Mvvm seems not to work. No ObservableProperty is updated in the UI nor a RelayCommand is reaching the code in the ViewModel. 

Is there a special requirement for this situation?

Best regards

Andreas



3 Replies 1 reply marked as answer

BV Brundha Velusamy Syncfusion Team November 12, 2024 10:04 AM UTC

Hi Andreas Schramm,


Thank you for reaching out to Syncfusion support!


To address the issue you're encountering, where the CommunityToolkit.MVVM properties and commands aren’t updating as expected within the SfNavigationDrawer ContentView, it’s essential to assign the BindingContext of the ContentPage to the NavigationDrawer ContentView as well. This ensures that the bindings from the CommunityToolkit.MVVM library work correctly within the navigation drawer.


Code Snippet

public partial class MainPage : ContentPage

{

    private Inbox inbox;

   

    public MainPage()

    {

        InitializeComponent();

        inbox = new Inbox();

       

        Initialize();          

    }

 

    private void Initialize()

    {

        navigationDrawer.ContentView = inbox.Content;

        navigationDrawer.ContentView.BindingContext = inbox.BindingContext;

    }

}


We've also attached a sample project implementing this approach for your reference. Please take a look, and let us know if you have further questions or need additional assistance.


Regards,

Brundha V


Attachment: SfNavigationDrawerSample_eb0f1d58.zip

Marked as answer

AS Andreas Schramm November 12, 2024 06:18 PM UTC

Dear  Brundha,


thank you very much! This works perfectly!


Best regards

Andreas



PR Preethi Rajakandham Syncfusion Team November 13, 2024 04:42 AM UTC

Hi Andreas Schramm,

You're Welcome. We are glad to know that the reported problem has been resolved. We are marking this thread as solved. Please let us know if you require any further assistance on this. We will be happy to assist you.

Regards,

Preethi R


Loader.
Up arrow icon