Using multiple controls in one screen

Hi, do you have any example of using more than one control at a time? I would like to have the Sftabview load an SfListview for one of the tabs. I would also like to use the SfPullToRefresh control with the list view. Is this possible? Following the guide for each item I have not been able to get them working together. I went back to a normal listview because SfListview was not loading in the tab.

Let me know if there is any example which combines these three controls

Regards,
George

10 Replies

MS Mugundhan Saravanan Syncfusion Team August 22, 2018 07:36 AM UTC

Hi George,

Thanks for contacting Syncfusion support.

Based upon your requirement we have prepared a sample with SfTabview, SfListView and SfPullToRefresh controls. In the sample we have SfList view in the SfTabView items and added the SfPulltorefresh control for the SfListview. Please find the sample from below link.

Sample: http://www.syncfusion.com/downloads/support/forum/139394/ze/TA2E96~1-647097918 
 
Please check our sample and let us know if you have any concerns.

Regards,
Mugundhan S 



GJ George Joshua August 22, 2018 06:16 PM UTC

Hi Mugundhan,
Thanks so much for the prompt reply. I found the error I was making before by examining your sample project. However, one thing that is missing which I would like to achieve is loading a separate binding context for each tab. I would like to load this when the tab is selected, rather than loading all data at the beginning as you do in your example. It works fine for simple data like you have, but for more complex views it will take too long to load. Can you tell me how to modify so that (for example) I have a separate ViewModel for each tab that is bound when swiping to that tab?

Thank you!
George


MS Mugundhan Saravanan Syncfusion Team August 24, 2018 03:27 AM UTC

Hi George Joshua,

Thanks for your update.

Based on your requirement we have modified the previously provided sample. In the sample we have used different view model to bind the itemsource of the SfListView for each tabitem. Please find the sample from the below link.

Sample Link: http://www.syncfusion.com/downloads/support/forum/139394/ze/TA0A87~1335316751 
 

Please let us know if you have any other concern.

Regards,
Mugundhan S. 



TS Troy Scheffel February 14, 2019 08:31 PM UTC

> (original question shortened) How to have a separate ViewModel for each tab?

The supplied project doesn't really answer this question.  Instead, the project sets the BindingContext of ListViews in each tab.  Thus the question remains: how can we set the BindingContext for ALL controls in a tab to a single ViewModel instance?  For example, I may have a tab with Labels, Buttons and a ListView and I want all those controls bound to a single ModelView instance (not just the ListView).  SfTabItem.BindingContext doesn't seem to work.

Thanks for your time.

Troy

License: Essential Studio Xamarin


MA Marcel replied to Troy Scheffel February 14, 2019 10:23 PM UTC

> (original question shortened) How to have a separate ViewModel for each tab?

The supplied project doesn't really answer this question.  Instead, the project sets the BindingContext of ListViews in each tab.  Thus the question remains: how can we set the BindingContext for ALL controls in a tab to a single ViewModel instance?  For example, I may have a tab with Labels, Buttons and a ListView and I want all those controls bound to a single ModelView instance (not just the ListView).  SfTabItem.BindingContext doesn't seem to work.

Thanks for your time.

Troy

License: Essential Studio Xamarin

Create a ContentView and put all controls inside this.
Binding this to your viewmodel
Include the ContentView in your tabview

This will not work in version 16.4.0.53 of the TabView control in Xamarin Forms 3.5 due to a bug



MS Mugundhan Saravanan Syncfusion Team February 15, 2019 06:01 PM UTC

Hi Marcel,

Thanks for your update.

Query: “SfTabItem.BindingContext doesn't seem to work.”.

We have already fixed the reported issue, and the fix will be included in our upcoming weekly nuget release. We will let you know once our weekly nuget has been rolled out.

Regards,
Mugundhan S.


TS Troy Scheffel February 15, 2019 07:40 PM UTC

Thank you to Marcel and Mugundhan for the info, appreciate it.

While waiting for the new release that Mugundhan mentioned, I have utilized the ContentView.BindingContext workaround that Marcel noted.  Works like a charm.

            <tabView:SfTabItem.Content>
                <ContentView>
                    <ContentView.BindingContext>
                        <vm:CommunicationViewModel />
                    </ContentView.BindingContext>
                    <ScrollView>
                        <controls:AuthenticatedWebView
                            x:Name="authenticatedWebView"
                            HorizontalOptions="FillAndExpand"
                            VerticalOptions="FillAndExpand"
            AuthenticationHeaderValue="{Binding BearerToken}"
                            Source="{Binding WebViewSource}"
                            Navigating="webOnNavigating"
                            Navigated="webOnNavigated" />
                    </ScrollView>
                </ContentView>
            </tabView:SfTabItem.Content>

Thanks again.
Troy


DR Dhanasekar R Syncfusion Team February 18, 2019 12:07 PM UTC

Hi Troy,  
  
Thanks for the update. We will let you know once rolled out  
  
Regards,  
Dhanasekar  
 
 



MA Marcel replied to Mugundhan Saravanan February 27, 2019 01:34 PM UTC

Hi Marcel,

Thanks for your update.

Query: “SfTabItem.BindingContext doesn't seem to work.”.

We have already fixed the reported issue, and the fix will be included in our upcoming weekly nuget release. We will let you know once our weekly nuget has been rolled out.

Regards,
Mugundhan S.

 Hi... 

Version 16.4.0.54 solved the problem in Android. But the problem persist in iOS.


Best Regards,


Marcel Souza
Pds Informática


DR Dhanasekar R Syncfusion Team March 1, 2019 03:56 AM UTC

Hi Marcel, 
 
Sorry for the inconvenience.  
 
The complete fix will be included in our upcoming 2019 Volume 1 release which is expected to be rolled out by Mid of March 2019. We will let you know once rolled out. 
 
Regards, 
Dhanasekar 


Loader.
Up arrow icon