MobileButtonStrip.xaml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <ContentView xmlns="http://xamarin.com/schemas/2014/forms"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
  4. xmlns:mobile="clr-namespace:InABox.Mobile;assembly=InABox.Mobile.Shared"
  5. x:Class="InABox.Mobile.MobileButtonStrip">
  6. <ContentView.Content>
  7. <ScrollView Orientation="Horizontal">
  8. <StackLayout Orientation="Horizontal"
  9. x:Name="_list"
  10. BackgroundColor="{Binding Source={RelativeSource Self}, Path=BackgroundColor}"
  11. HeightRequest="40">
  12. <BindableLayout.ItemTemplate>
  13. <DataTemplate x:DataType="mobile:MobileButtonStripItem">
  14. <mobile:MobileCard
  15. BorderColor="{Binding Source={RelativeSource AncestorType={x:Type mobile:MobileButtonStrip}}, Path=BorderColor}"
  16. BackgroundColor="{Binding Source={RelativeSource AncestorType={x:Type mobile:MobileButtonStrip}}, Path=UnselectedBackgroundColor}">
  17. <mobile:MobileCard.Triggers>
  18. <DataTrigger TargetType="mobile:MobileCard" Binding="{Binding Selected}" Value="True">
  19. <Setter Property="BackgroundColor" Value="{Binding Source={RelativeSource AncestorType={x:Type mobile:MobileButtonStrip}}, Path=SelectedBackgroundColor}" />
  20. </DataTrigger>
  21. </mobile:MobileCard.Triggers>
  22. <Label
  23. x:Name="_label"
  24. Text="{Binding Text}"
  25. FontSize="{Binding Source={RelativeSource AncestorType={x:Type mobile:MobileButtonStrip}}, Path=FontSize}"
  26. FontAttributes="{Binding Source={RelativeSource AncestorType={x:Type mobile:MobileButtonStrip}}, Path=FontAttributes}"
  27. HorizontalTextAlignment="Center"
  28. VerticalTextAlignment="Center"
  29. BackgroundColor="Transparent"
  30. TextColor="{Binding Source={RelativeSource AncestorType={x:Type mobile:MobileButtonStrip}}, Path=UnselectedForegroundColor}"
  31. Margin="5,0">
  32. <Label.GestureRecognizers>
  33. <TapGestureRecognizer Tapped="DoTap" />
  34. </Label.GestureRecognizers>
  35. <Label.Triggers>
  36. <DataTrigger TargetType="Label" Binding="{Binding Selected}" Value="True">
  37. <Setter Property="TextColor" Value="{Binding Source={RelativeSource AncestorType={x:Type mobile:MobileButtonStrip}}, Path=SelectedForegroundColor}" />
  38. </DataTrigger>
  39. </Label.Triggers>
  40. </Label>
  41. </mobile:MobileCard>
  42. </DataTemplate>
  43. </BindableLayout.ItemTemplate>
  44. </StackLayout>
  45. </ScrollView>
  46. </ContentView.Content>
  47. </ContentView>