Last active
August 29, 2015 14:23
-
-
Save chrisriesgo/6a5bc0f838c366cb3815 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void ItemsSourceChanged () | |
{ | |
if (ItemsSource == null) return; | |
CreateTabs(); | |
} | |
void CreateTabs() | |
{ | |
if(Children != null && Children.Count > 0) Children.Clear(); | |
foreach(var item in ItemsSource) | |
{ | |
var index = Children.Count; | |
var tab = new StackLayout { | |
Orientation = StackOrientation.Vertical, | |
HorizontalOptions = LayoutOptions.Center, | |
VerticalOptions = LayoutOptions.Center, | |
Padding = new Thickness(7), | |
}; | |
Device.OnPlatform( | |
iOS: () => | |
{ | |
tab.Children.Add(new Image { Source = "pin.png", HeightRequest = 20 }); | |
tab.Children.Add(new Label { Text = "Tab " + (index + 1), FontSize = 11 }); | |
}, | |
Android: () => | |
{ | |
tab.Children.Add(new Image { Source = "pin.png", HeightRequest = 25 }); | |
} | |
); | |
var tgr = new TapGestureRecognizer(); | |
tgr.Command = new Command(() => | |
{ | |
SelectedItem = ItemsSource[index]; | |
}); | |
tab.GestureRecognizers.Add(tgr); | |
Children.Add(tab, index, 0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment