2
0

UdpLogListBox.xaml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. FocusVisualStyle="{x:Null}"
  14. VirtualizingPanel.IsVirtualizing="True"
  15. ScrollViewer.CanContentScroll="True"
  16. ScrollViewer.HorizontalScrollBarVisibility="Disabled"
  17. BorderThickness="0"
  18. Background="#f7f7f7">
  19. <ListBox.ItemContainerStyle>
  20. <Style TargetType="{x:Type ListBoxItem}">
  21. <Setter Property="FocusVisualStyle" Value="{x:Null}" />
  22. <Style.Triggers>
  23. <Trigger Property="IsSelected" Value="True">
  24. <Setter Property="FocusManager.FocusedElement" Value="{Binding RelativeSource={RelativeSource Self}}" />
  25. </Trigger>
  26. </Style.Triggers>
  27. </Style>
  28. </ListBox.ItemContainerStyle>
  29. <ListBox.ItemTemplate>
  30. <DataTemplate>
  31. <StackPanel Margin="16 5">
  32. <StackPanel.ContextMenu>
  33. <ContextMenu>
  34. <MenuItem Header="复制本项" Click="MenuItem_Copy_Click" />
  35. <MenuItem Header="清除所有" Click="MenuItem_Clear_Click" />
  36. </ContextMenu>
  37. </StackPanel.ContextMenu>
  38. <TextBlock TextWrapping="Wrap" FontSize="13" Margin="0 2" Text="{Binding Timestamp, StringFormat={}{0:yyyy-MM-dd HH:mm:ss.fff}}"/>
  39. <TextBlock TextWrapping="Wrap" FontSize="14" Margin="0 2" FontWeight="Light" Text="{Binding Message}">
  40. <TextBlock.Foreground>
  41. <SolidColorBrush Color="{Binding Color}"/>
  42. </TextBlock.Foreground>
  43. </TextBlock>
  44. </StackPanel>
  45. </DataTemplate>
  46. </ListBox.ItemTemplate>
  47. </ListBox>
  48. </Grid>
  49. </UserControl>