We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to get a sftabview and sflistview information at the same time?

Hi in my XAML I have a SfListView and a SfTabView and at a moment I have the follow code:




EventName="TabItemTapped" Command="{ Binding SelectionChangedCommand }"
CommandParameter="{ Binding Source={ x:Reference lvAgreements }}" />


...

At CommandParameter I want have something like that CommandParameter="{ Binding Source={ x:Reference lvAgreements, tbvMenuBottom }}" />

I need to get sfListView and the sfTabView information in my ViewModel.

How can I get it?

6 Replies

MK Muneesh Kumar G Syncfusion Team June 4, 2019 12:02 PM UTC

Hi Vially, 
 
Greetings from Syncfusion. 
 
We have validated your query and created a sample to achieve your requirement. Please find the sample from below link. 
 
 
In this sample, we have done the following things, 
 
1. Added TabItemTapped command to the SfTabview using Event to command behavior. 
 
2. Get the SfTabItem as the arguments from TapItemTapped as like below code snippet 
 

        void OnTapped(Object obj)
        {
            model.Arguments = (obj as Syncfusion.XForms.TabView.TabItemTappedEventArgs)?.TabItem;
            model.TabHeaderPosition = ((obj as Syncfusion.XForms.TabView.TabItemTappedEventArgs)?.TabItem.Parent as SfTabView).TabHeaderPosition;
        } 
 
Now, you can get the SfListView and information from the tab item content as like below code snippet 
 
 var content = (obj as Syncfusion.XForms.TabView.TabItemTappedEventArgs)?.TabItem.Content; 
 
We request you to try our sample and If your requirement is different from this, could you please share more information about this. 
 
This will be helpful for us to provide you a good solution and improve us to serve you better. 
  
Regards, 
Muneesh Kumar G. 



VI Vially Israel June 4, 2019 09:30 PM UTC

Hi, Muneesh.

You helped me a little, but was because I forgot to explain one more thing, sorry.

I want when I click in the menutab button do create a PushAsync Page.

If I use

< tabview:SfTabView.Behaviors >
                    < helper:EventToCommandBehavior EventName="TabItemTapped" Command="{ Binding TappedCommand }" CommandParameter="{ Binding Arguments }" / >
               

I can create the page when click in the first button. But if I click in another button I get an error after my PushAsync in my ViewModel. I guess is because the tabview wants to change the focus on the button.

So, what event I can use in this case? TabItemTapped doens't work in this case.



VI Vially Israel June 5, 2019 07:01 PM UTC

I discovered the error is: Exception thrown: 'System.NullReferenceException' in Syncfusion.SfTabView.XForms.UWP.dll

The error happens in UWP project. In the Android it doesn't.


MK Muneesh Kumar G Syncfusion Team June 6, 2019 01:46 PM UTC

Hi Vially,  
 
We have validated the reported issue in SfTabView. And we would like to inform you that you have navigated to next page in OnTapped method, this causes the SfTabView to be disposed and hence the crash occurred.  
 
We have other processes running like animation after the selection is changed. You can resolve this problem by using Task.Delay before the navigation as per the below code snippet.  
 
Code snippet 
 
await Task.Delay(1);
await this.Navigation.PushModalAsync(new SecondPage());
 
 
  
Please find the sample from below link 
 
Please let us know if you have any other queries.  
  
Regards,  
Muneesh Kumar G.  



VI Vially Israel June 6, 2019 06:47 PM UTC

Hi, Muneesh!

Thanks! It's work!


MK Muneesh Kumar G Syncfusion Team June 7, 2019 05:42 AM UTC

Hi Vially, 
 
Thanks for the update. 
  
We are glad to know that the given solution works. Please let us know if you need any further assistance. 
 
Regards, 
Muneesh Kumar G. 


Loader.
Live Chat Icon For mobile
Up arrow icon