UdpLogListBox.xaml 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <UserControl x:Class="FastGithub.UI.UdpLogListBox"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:local="clr-namespace:FastGithub.UI"
  7. mc:Ignorable="d"
  8. d:DesignHeight="450" d:DesignWidth="800">
  9. <Grid>
  10. <ListBox
  11. x:Name="listBox"
  12. ItemsSource="{Binding LogList}"
  13. VirtualizingPanel.IsVirtualizing="True"
  14. ScrollViewer.CanContentScroll="True"
  15. ScrollViewer.HorizontalScrollBarVisibility="Disabled"
  16. BorderThickness="0"
  17. Background="#f7f7f7">
  18. <ListBox.ItemContainerStyle>
  19. <Style TargetType="{x:Type ListBoxItem}">
  20. <Setter Property="FocusVisualStyle" Value="{x:Null}" />
  21. <Style.Triggers>
  22. <Trigger Property="IsSelected" Value="True">
  23. <Setter Property="FocusManager.FocusedElement" Value="{Binding RelativeSource={RelativeSource Self}}" />
  24. </Trigger>
  25. </Style.Triggers>
  26. </Style>
  27. </ListBox.ItemContainerStyle>
  28. <ListBox.ItemTemplate>
  29. <DataTemplate>
  30. <StackPanel Margin="16 5">
  31. <StackPanel.ContextMenu>
  32. <ContextMenu>
  33. <MenuItem Header="复制本项" Click="MenuItem_Copy_Click" />
  34. <MenuItem Header="清除所有" Click="MenuItem_Clear_Click" />
  35. </ContextMenu>
  36. </StackPanel.ContextMenu>
  37. <TextBlock TextWrapping="Wrap" FontSize="13" Margin="0 2" Text="{Binding Timestamp, StringFormat={}{0:yyyy-MM-dd HH:mm:ss.fff}}"/>
  38. <TextBlock TextWrapping="Wrap" FontSize="14" Margin="0 2" FontWeight="Light" Text="{Binding Message}">
  39. <TextBlock.Foreground>
  40. <SolidColorBrush Color="{Binding Color}"/>
  41. </TextBlock.Foreground>
  42. </TextBlock>
  43. </StackPanel>
  44. </DataTemplate>
  45. </ListBox.ItemTemplate>
  46. </ListBox>
  47. </Grid>
  48. </UserControl>