Navigation Drawer Binding not working


<navigationdrawer:SfNavigationDrawer.DrawerSettings>
         <navigationdrawer:DrawerSettings DrawerHeaderHeight="0" 
                                          DrawerFooterHeight="0"
                                          DrawerWidth="{Binding ItsColumnWidth}"
                                          Position="Right" EnableSwipeGesture="False">
               <navigationdrawer:DrawerSettings.DrawerContentView>
                    //Some Content
               </navigationdrawer:DrawerSettings.DrawerContentView>
</navigationdrawer:DrawerSettings>

I have binded ItsColumnWidth with DrawerWidth Property.  

public double ItsColumnWidth
{
    get => _columnWidth;
    set
    {
        if (value == _columnWidth) return;
        _columnWidth = value;
        RaisePropertyChanged(nameof(ItsColumnWidth));
    }
}

But DrawerWidth ​isn't changing though ItsColumnWidth is changing from view models. view model is working fine. If I bind a general Label from that view model, it's working. 

Could you please address this issue and let me know work around for this?


1 Reply

KP Kamalesh Periyasamy Syncfusion Team March 5, 2024 09:27 AM UTC

Hi Sabbir,


After validating the reported query, we were able to reproduce the issue on our end. To address this, we recommend setting an x:Name for the ViewModel class and using this name as the source reference for the DrawerWidth property as shown in the code snippet below. For your convenience, we have prepared a sample demonstrating this solution and attached it for your reference.


Code snippet:

 <ContentPage.BindingContext>

     <local:DrawerViewModel x:Name="viewModel"/>

 </ContentPage.BindingContext>

 

 <navigationdrawer:SfNavigationDrawer x:Name="navigationDrawer">

     <navigationdrawer:SfNavigationDrawer.DrawerSettings>

         <navigationdrawer:DrawerSettings DrawerHeaderHeight="0"

                                           DrawerFooterHeight="0"

                                           DrawerWidth="{Binding ItsColumnWidth,Source={x:Reference viewModel}}"

                                           Position="Right"

                                           EnableSwipeGesture="False">

             <navigationdrawer:DrawerSettings.DrawerContentView>


Kindly review the attached file and let us know if it resolves the issue you were encountering. If you have any further questions or need additional assistance, please feel free to ask.


Regards,
Kamalesh P


Attachment: GettingStarted_9432be54.zip

Loader.
Up arrow icon