ListViewButton.axaml 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <Styles xmlns="https://github.com/avaloniaui"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:components="using:InABox.Avalonia.Components"
  4. xmlns:converters="using:InABox.Avalonia.Converters">
  5. <Style Selector="components|ListViewButton">
  6. <Style.Resources>
  7. <converters:DoubleToCornerRadiusConverter
  8. x:Key="SphericalBorder"
  9. Ratio="0.5" />
  10. <converters:DoubleToThicknessConverter
  11. x:Key="MarginDoubler"
  12. Ratio="2.0" />
  13. </Style.Resources>
  14. <Setter Property="Template">
  15. <ControlTemplate>
  16. <Button Height="80"
  17. Padding="0"
  18. Background="{TemplateBinding Background}"
  19. Foreground="{TemplateBinding Foreground}"
  20. BorderBrush="{StaticResource PrsTileBorder}"
  21. HorizontalContentAlignment="Stretch"
  22. VerticalContentAlignment="Stretch"
  23. Command="{TemplateBinding Command}"
  24. CommandParameter="{TemplateBinding CommandParameter}">
  25. <Grid>
  26. <Grid.RowDefinitions>
  27. <RowDefinition Height="*" />
  28. <RowDefinition Height="1.2*" />
  29. </Grid.RowDefinitions>
  30. <Grid.ColumnDefinitions>
  31. <ColumnDefinition Width="70" />
  32. <ColumnDefinition Width="*" />
  33. </Grid.ColumnDefinitions>
  34. <Image
  35. Classes="Large"
  36. Grid.Row="0"
  37. Grid.Column="0"
  38. Grid.RowSpan="2"
  39. Source="{TemplateBinding Image}"
  40. HorizontalAlignment="Center"
  41. VerticalAlignment="Center" />
  42. <Label
  43. Grid.Row="0"
  44. Grid.Column="1"
  45. VerticalAlignment="Stretch"
  46. VerticalContentAlignment="Center"
  47. FontSize="{StaticResource PrsFontSizeLarge}"
  48. FontWeight="{StaticResource PrsFontWeightBold}"
  49. Content="{TemplateBinding Title}" />
  50. <TextBlock
  51. Grid.Row="1"
  52. Grid.Column="1"
  53. FontSize="{StaticResource PrsFontSizeNormal}"
  54. FontStyle="{StaticResource PrsFontStylItalic}"
  55. TextWrapping="WrapWithOverflow"
  56. VerticalAlignment="Stretch"
  57. Text="{TemplateBinding Description}" />
  58. <Border
  59. Background="{StaticResource PrsTileBackground}"
  60. BorderBrush="{StaticResource PrsTileBorder}"
  61. Grid.Row="0"
  62. Grid.RowSpan="2"
  63. Grid.Column="1"
  64. VerticalAlignment="Top"
  65. HorizontalAlignment="Right"
  66. IsVisible="{TemplateBinding Alert, Converter={StaticResource StringToBooleanConverter}}"
  67. MinWidth="{Binding $self.Bounds.Height}"
  68. Margin="{Binding $self, Converter={StaticResource MarginDoubler}, ConverterParameter={StaticResource PrsControlSpacing}}"
  69. CornerRadius="{Binding $self.Bounds.Height, Converter={StaticResource SphericalBorder}}">
  70. <Label
  71. Background="Transparent"
  72. Foreground="{StaticResource PrsTileForeground}"
  73. HorizontalContentAlignment="Center"
  74. Content="{TemplateBinding Alert}" />
  75. </Border>
  76. </Grid>
  77. </Button>
  78. </ControlTemplate>
  79. </Setter>
  80. </Style>
  81. </Styles>