MobileButtonStrip.xaml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. <CollectionView
  8. x:Name="_list"
  9. BackgroundColor="{Binding Source={RelativeSource Self}, Path=BackgroundColor}"
  10. ItemSizingStrategy="MeasureAllItems"
  11. SelectionMode="None"
  12. HeightRequest="40">
  13. <CollectionView.ItemsLayout>
  14. <LinearItemsLayout x:Name="_layout" ItemSpacing="5" Orientation="Horizontal" />
  15. </CollectionView.ItemsLayout>
  16. <CollectionView.ItemTemplate>
  17. <DataTemplate x:DataType="mobile:MobileButtonStripItem">
  18. <mobile:MobileCard
  19. BorderColor="{Binding Source={RelativeSource AncestorType={x:Type mobile:MobileButtonStrip}}, Path=BorderColor}"
  20. BackgroundColor="{Binding Source={RelativeSource AncestorType={x:Type mobile:MobileButtonStrip}}, Path=UnselectedBackgroundColor}">
  21. <mobile:MobileCard.Triggers>
  22. <DataTrigger TargetType="mobile:MobileCard" Binding="{Binding Selected}" Value="True">
  23. <Setter Property="BackgroundColor" Value="{Binding Source={RelativeSource AncestorType={x:Type mobile:MobileButtonStrip}}, Path=SelectedBackgroundColor}" />
  24. </DataTrigger>
  25. </mobile:MobileCard.Triggers>
  26. <Label
  27. x:Name="_label"
  28. Text="{Binding Text}"
  29. FontSize="{Binding Source={RelativeSource AncestorType={x:Type mobile:MobileButtonStrip}}, Path=FontSize}"
  30. FontAttributes="{Binding Source={RelativeSource AncestorType={x:Type mobile:MobileButtonStrip}}, Path=FontAttributes}"
  31. HorizontalTextAlignment="Center"
  32. VerticalTextAlignment="Center"
  33. BackgroundColor="Transparent"
  34. TextColor="{Binding Source={RelativeSource AncestorType={x:Type mobile:MobileButtonStrip}}, Path=UnselectedForegroundColor}"
  35. Margin="5,0">
  36. <Label.GestureRecognizers>
  37. <TapGestureRecognizer Tapped="DoTap" />
  38. </Label.GestureRecognizers>
  39. <Label.Triggers>
  40. <DataTrigger TargetType="Label" Binding="{Binding Selected}" Value="True">
  41. <Setter Property="TextColor" Value="{Binding Source={RelativeSource AncestorType={x:Type mobile:MobileButtonStrip}}, Path=SelectedForegroundColor}" />
  42. </DataTrigger>
  43. </Label.Triggers>
  44. </Label>
  45. </mobile:MobileCard>
  46. </DataTemplate>
  47. </CollectionView.ItemTemplate>
  48. </CollectionView>
  49. </ContentView.Content>
  50. </ContentView>