MobileButtonStrip.xaml 3.5 KB

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