I first thought I could add the gesture via a GestureListener in a Custom Renderer, however this causes issues when trying to swipe while showing a full screen button or ListView, as these two controls consume the Gestures, so this wasn't an option.
I then had an idea about combining a CarouselPage and TabbedPage, hence this post.
This is very convoluted and will not perform very well when used in complex UI layouts, but it might be useful.
First the XAML :-
As you can see this layout won't work for Windows Phone and I haven't tested this on iOS however I am only really targeting Android at the moment.
Next is the C# :-
public partial class MainPage : TabbedPage { public MainPage() { InitializeComponent(); AttachCurrentPageChanged(); } private void AttachCurrentPageChanged() { Page1.CurrentPageChanged += MultiPage_OnCurrentPageChanged; Page2.CurrentPageChanged += MultiPage_OnCurrentPageChanged; Page3.CurrentPageChanged += MultiPage_OnCurrentPageChanged; } private void DetachCurrentPageChanged() { Page1.CurrentPageChanged -= MultiPage_OnCurrentPageChanged; Page2.CurrentPageChanged -= MultiPage_OnCurrentPageChanged; Page3.CurrentPageChanged -= MultiPage_OnCurrentPageChanged; } private void MultiPage_OnCurrentPageChanged(object sender, EventArgs e) { DetachCurrentPageChanged(); CarouselPage carouselPage = sender as CarouselPage; if (carouselPage != null) { int indexOf = carouselPage.Children.IndexOf(carouselPage.CurrentPage); var tabbedPage = carouselPage.ParentView as TabbedPage; if (tabbedPage != null) { tabbedPage.CurrentPage = tabbedPage.Children[indexOf]; var newCarouselPage = tabbedPage.CurrentPage as CarouselPage; if (newCarouselPage != null) { newCarouselPage.CurrentPage = newCarouselPage.Children[indexOf]; } } } AttachCurrentPageChanged(); } }The OnCurrentPageChanged is used to track the Page Change of the CarouselPage, the index of this page is then used to set the CurrentPage of the next CarouselPage.
As this tracking needs to occur the number of child Pages in each of the CarouselPages needs to equal the numbwe of Tabs you would like to show.
If you want to add more Tabs, you add more CarouselPage's as children of the TabbedPage and then ensure that each CarouselPage is updated with the correct number of children.
This is by far an ideal solution but was interesting nevertheless.
The complete sample is here :-
http://www.smartmobiledevice.co.uk/Samples/Xamarin/SwipeTabbedPageSample.zip
cool tweak. swipe works perfect. but clicking on the tab header is not going to new tab page.
ReplyDeletefound a solution for it.. added below code worked for me. thanks for the sample.
ReplyDeletethis.CurrentPageChanged += MultiPage1_OnCurrentPageChanged;
private void MultiPage1_OnCurrentPageChanged(object sender, EventArgs e)
{
TabbedPage tabbedPage = sender as TabbedPage;
if (tabbedPage != null) {
CarouselPage currentPage = tabbedPage.CurrentPage as CarouselPage;
currentPage.CurrentPage = currentPage.Children[tabbedPage.Children.IndexOf(tabbedPage.CurrentPage)];
}
}
Download link is not working. please provide working link
ReplyDeleteThanks in adavnce
Hi,
ReplyDeletei tried this solution. it works for upto 3 tabs. For more than 3 it is not showing second tab page in Android.
Please help
Thanks in advance
For three tabs three content pages added. Then for 4 tabs you should add 4 content page as shown.
DeleteI really thank the author of this article, the article has great significance for me, it just leads me to do better things for this life. Very meaningful, thank you very much,
ReplyDeleteHappy Mothers Day Wallpaper Mothers day images HD 2016
Mothers day wishes status mothers day 2016 Vector images
Wishing Mother day whatsapp Status messages sms for mothers day facebook wallpaper pictures mothers day messages quotes
Download mother day 2016 wallpaper in Malayalam text wishing mothers day images mothers day background wallpaper mothers day wishing photos
Best wishing sms mothers day 2016 messages Happy mothers day card quotes
I love my mom mothers day wishes wallpaper poems
Thanks for the nice blog. It was very useful for me. Keep sharing such ideas in the future as well. This was actually what I was looking for, and I am glad to came here! Thanks for sharing the such information with us
ReplyDeleteI love my mothers messages status quotes mothers day pictures wallpaper
Wishing Mother day poem i love you mom poems mothers day messages wishes quotes mom day pics
mothers day 2016 poems in Hindi English Marathi Malayalam wishing mother day wallpaper images
Mothers day Flowers mother day Craft Mothers day Special messages for mom
Best mother day sms mothers day messages with images mothers day 2016 wallpaper Mothers day clipart
Happy mom day text message mothers day wishes card pictures
mothers day hand made craft idea mothers day wishing greeting cards 2016
Mothers day Banner 2016 mothers day Clip art mothers day animated wallpaper images
Happy mothers day banners mothers day messages with wallpapers
Wishing Mother day banner card mother day greeting quotes
ReplyDeleteMother day clip art Happy mothers day wallpaper images short line messages status for mothers day mother day 2016 quotes
Mothers day greeting cards mothers day Ecards Mothers day hd cards with text messages
Mothers day greeting cards Happy Mothers day wishes Mothers day wallpaper Mothers day images 2016
Happy mom day ecards Mothers day wishes card Mothers day greeting cards
Mothers day ecards Mothers day greeting card Mothers day banner for facebook Mothers day facebook messages wallpaper
any idea how to implement this for windows 8.1 using xamarin forms
ReplyDeleteany idea how to implement this for windows 8.1 using xamarin forms
ReplyDelete