ChatPageView.axaml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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:vm="using:VirtualizationDemo.ViewModels"
  6. mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
  7. x:Class="VirtualizationDemo.Views.ChatPageView"
  8. x:DataType="vm:ChatPageViewModel">
  9. <ListBox ItemsSource="{Binding Messages}">
  10. <ListBox.ItemContainerTheme>
  11. <ControlTheme TargetType="ListBoxItem" BasedOn="{StaticResource {x:Type ListBoxItem}}">
  12. <Setter Property="Padding" Value="8"/>
  13. </ControlTheme>
  14. </ListBox.ItemContainerTheme>
  15. <ListBox.ItemTemplate>
  16. <DataTemplate>
  17. <Border CornerRadius="8"
  18. Background="{DynamicResource SystemControlBackgroundAltHighBrush}"
  19. TextElement.Foreground="{DynamicResource SystemControlForegroundBaseHighBrush}"
  20. Padding="6"
  21. HorizontalAlignment="Left"
  22. MaxWidth="280">
  23. <DockPanel>
  24. <TextBlock DockPanel.Dock="Top"
  25. Text="{Binding Sender}"
  26. FontWeight="Bold"/>
  27. <TextBlock DockPanel.Dock="Bottom"
  28. Text="{Binding Timestamp}"
  29. FontSize="10"
  30. Foreground="{DynamicResource SystemControlForegroundBaseMediumBrush}"
  31. TextAlignment="Right"
  32. Margin="0 4 0 0"/>
  33. <TextBlock Text="{Binding Message}" TextWrapping="Wrap"/>
  34. </DockPanel>
  35. </Border>
  36. </DataTemplate>
  37. </ListBox.ItemTemplate>
  38. </ListBox>
  39. </UserControl>