AvaloniaModuleList.axaml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <UserControl xmlns="https://github.com/avaloniaui"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  4. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5. xmlns:converters="clr-namespace:InABox.Avalonia.Converters;assembly=InABox.Avalonia"
  6. xmlns:components="clr-namespace:InABox.Avalonia.Components"
  7. mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
  8. x:Class="InABox.Avalonia.Components.AvaloniaModuleList"
  9. x:DataType="components:AvaloniaModuleList">
  10. <UserControl.Resources>
  11. <converters:StringToColorConverter
  12. x:Key="ModuleAlertBackgroundConverter"
  13. Color="{StaticResource PrsAlertBackground}"
  14. Empty="{StaticResource PrsTileBackground}" />
  15. <converters:DoubleToCornerRadiusConverter
  16. x:Key="SphericalBorder"
  17. Ratio="0.5" />
  18. <converters:DoubleToThicknessConverter
  19. x:Key="MarginInverter"
  20. Ratio="-1.0" />
  21. <converters:DoubleToThicknessConverter
  22. x:Key="MarginDoubler"
  23. Ratio="2.0" />
  24. <DataTemplate
  25. x:Key="ModuleList"
  26. x:DataType="components:AvaloniaModule">
  27. <Button Classes="Standard"
  28. Height="80"
  29. Padding="0"
  30. Background="{Binding Alert, Converter={StaticResource ModuleAlertBackgroundConverter}}"
  31. BorderBrush="{StaticResource PrsTileBorder}"
  32. Foreground="{StaticResource PrsTileForeground}"
  33. HorizontalContentAlignment="Stretch"
  34. VerticalContentAlignment="Stretch"
  35. Command="{Binding TapCommand}">
  36. <Grid>
  37. <Grid.RowDefinitions>
  38. <RowDefinition Height="*" />
  39. <RowDefinition Height="1.2*" />
  40. </Grid.RowDefinitions>
  41. <Grid.ColumnDefinitions>
  42. <ColumnDefinition Width="70" />
  43. <ColumnDefinition Width="*" />
  44. </Grid.ColumnDefinitions>
  45. <Image
  46. Classes="Large"
  47. Grid.Row="0"
  48. Grid.Column="0"
  49. Grid.RowSpan="2"
  50. Source="{Binding Image}"
  51. HorizontalAlignment="Center"
  52. VerticalAlignment="Center" />
  53. <Label
  54. Grid.Row="0"
  55. Grid.Column="1"
  56. VerticalAlignment="Stretch"
  57. VerticalContentAlignment="Center"
  58. FontSize="{StaticResource PrsFontSizeLarge}"
  59. FontWeight="{StaticResource PrsFontWeightBold}"
  60. Content="{Binding Title}" />
  61. <TextBlock
  62. Grid.Row="1"
  63. Grid.Column="1"
  64. FontSize="{StaticResource PrsFontSizeNormal}"
  65. FontStyle="{StaticResource PrsFontStylItalic}"
  66. TextWrapping="WrapWithOverflow"
  67. VerticalAlignment="Stretch"
  68. Text="{Binding Description}" />
  69. <Border
  70. Background="{StaticResource PrsTileBackground}"
  71. BorderBrush="{StaticResource PrsTileBorder}"
  72. Grid.Row="0"
  73. Grid.RowSpan="2"
  74. Grid.Column="1"
  75. VerticalAlignment="Top"
  76. HorizontalAlignment="Right"
  77. Margin="{Binding Converter={StaticResource MarginDoubler}, ConverterParameter={StaticResource PrsControlSpacing}}"
  78. IsVisible="{Binding Alert, Converter={StaticResource StringToBooleanConverter}}"
  79. MinWidth="{Binding $self.Bounds.Height}"
  80. CornerRadius="{Binding $self.Bounds.Height, Converter={StaticResource SphericalBorder}}">
  81. <Label
  82. Background="Transparent"
  83. Foreground="{StaticResource PrsTileForeground}"
  84. HorizontalContentAlignment="Center"
  85. Content="{Binding Alert}" />
  86. </Border>
  87. </Grid>
  88. </Button>
  89. </DataTemplate>
  90. </UserControl.Resources>
  91. <ItemsControl
  92. DataContext="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType = components:AvaloniaModuleList}}"
  93. ItemsSource="{Binding Modules.VisibleItems}"
  94. ItemTemplate="{StaticResource ModuleList}"
  95. Margin="{Binding Converter={StaticResource MarginInverter}, ConverterParameter={StaticResource PrsControlSpacing}}" />
  96. </UserControl>