MobileButtonStrip.xaml 3.0 KB

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