FastGithub/FastGithub.UI/UdpLogListBox.xaml
xingyuan55 4d9d97f871 start
2022-11-16 08:01:03 +08:00

50 lines
2.5 KiB
XML

<UserControl x:Class="FastGithub.UI.UdpLogListBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:FastGithub.UI"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<ListBox
x:Name="listBox"
ItemsSource="{Binding LogList}"
FocusVisualStyle="{x:Null}"
VirtualizingPanel.IsVirtualizing="True"
ScrollViewer.CanContentScroll="True"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
BorderThickness="0"
Background="#f7f7f7">
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="FocusManager.FocusedElement" Value="{Binding RelativeSource={RelativeSource Self}}" />
</Trigger>
</Style.Triggers>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="16 5">
<StackPanel.ContextMenu>
<ContextMenu>
<MenuItem Header="复制本项" Click="MenuItem_Copy_Click" />
<MenuItem Header="清除所有" Click="MenuItem_Clear_Click" />
</ContextMenu>
</StackPanel.ContextMenu>
<TextBlock TextWrapping="Wrap" FontSize="13" Margin="0 2" Text="{Binding Timestamp, StringFormat={}{0:yyyy-MM-dd HH:mm:ss.fff}}"/>
<TextBlock TextWrapping="Wrap" FontSize="14" Margin="0 2" FontWeight="Light" Text="{Binding Message}">
<TextBlock.Foreground>
<SolidColorBrush Color="{Binding Color}"/>
</TextBlock.Foreground>
</TextBlock>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</UserControl>