LogsView.axaml 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <UserControl
  2. x:Class="ShakerApp.Views.LogsView"
  3. xmlns="https://github.com/avaloniaui"
  4. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  7. xmlns:vm="using:ShakerApp.ViewModels"
  8. d:DesignHeight="450"
  9. d:DesignWidth="800"
  10. x:DataType="vm:LogViewModel"
  11. Background="Transparent"
  12. DataContext="{Binding Source={x:Static vm:LogViewModel.Instance}}"
  13. mc:Ignorable="d">
  14. <StackPanel Background="Transparent">
  15. <Grid
  16. Height="{StaticResource ItemHeight}"
  17. Background="LightGray"
  18. ColumnDefinitions="40,0.5*,*">
  19. <TextBlock
  20. HorizontalAlignment="Center"
  21. VerticalAlignment="Center"
  22. Text="{DynamicResource ServoValveIndex}" />
  23. <TextBlock
  24. Grid.Column="1"
  25. HorizontalAlignment="Center"
  26. VerticalAlignment="Center"
  27. Text="{DynamicResource Time}" />
  28. <TextBlock
  29. Grid.Column="2"
  30. HorizontalAlignment="Center"
  31. VerticalAlignment="Center"
  32. Text="{DynamicResource Message}" />
  33. </Grid>
  34. <ScrollViewer Height="{Binding $parent.Bounds.Height, Converter={StaticResource SubtractionConverter}, ConverterParameter={StaticResource ItemHeight}}">
  35. <ItemsControl ItemsSource="{Binding Logs}">
  36. <ItemsControl.ItemTemplate>
  37. <DataTemplate>
  38. <Grid Height="{StaticResource ItemHeight}" ColumnDefinitions="40,0.5*,*">
  39. <Grid.Styles>
  40. <Style Selector="TextBlock.Error">
  41. <Setter Property="Foreground" Value="Red" />
  42. </Style>
  43. </Grid.Styles>
  44. <TextBlock
  45. HorizontalAlignment="Center"
  46. VerticalAlignment="Center"
  47. Classes.Error="{Binding Value.LogType, Converter={StaticResource EnumToBooleanConverter}, ConverterParameter={x:Static vm:LogType.Error}}"
  48. Text="{Binding Index}" />
  49. <TextBlock
  50. Grid.Column="1"
  51. HorizontalAlignment="Center"
  52. VerticalAlignment="Center"
  53. Classes.Error="{Binding Value.LogType, Converter={StaticResource EnumToBooleanConverter}, ConverterParameter={x:Static vm:LogType.Error}}"
  54. Text="{Binding Value.DateTime, StringFormat='{}{0:yyyy-MM-dd HH:mm:ss.fff}'}" />
  55. <TextBlock
  56. Grid.Column="2"
  57. HorizontalAlignment="Center"
  58. VerticalAlignment="Center"
  59. Classes.Error="{Binding Value.LogType, Converter={StaticResource EnumToBooleanConverter}, ConverterParameter={x:Static vm:LogType.Error}}"
  60. Text="{Binding Value.Message}" />
  61. </Grid>
  62. </DataTemplate>
  63. </ItemsControl.ItemTemplate>
  64. </ItemsControl>
  65. </ScrollViewer>
  66. </StackPanel>
  67. </UserControl>