-
Notifications
You must be signed in to change notification settings - Fork 2
/
MainWindow.xaml
78 lines (72 loc) · 2.21 KB
/
MainWindow.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
Width="800" Height="600"
x:Class="AvaloniaListBoxBug.MainWindow"
xmlns:models="clr-namespace:AvaloniaListBoxBug.Models;assembly=AvaloniaListBoxBug"
Title="AvaloniaBug1">
<Grid RowDefinitions="Auto,*">
<StackPanel Orientation="Horizontal">
<Button Content="ScrollToEnd" Click="BtnScrollToEnd_Click"/>
</StackPanel>
<ListBox
Name="MessageList"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ItemsSource="{Binding Items}"
Grid.Row="1">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.DataTemplates>
<DataTemplate DataType="{x:Type models:UnEvenItem}">
<Grid ColumnDefinitions="Auto, Auto, *">
<TextBlock
Grid.Column="0"
Text="{Binding TimeStamp, StringFormat=\{0:T\}}"
FontWeight="Bold" />
<TextBlock
Grid.Column="1"
Margin="10 0 0 0"
Foreground="Red"
FontSize="14"
FontWeight="Bold"
Text="{Binding Id}" />
<TextBlock
Grid.Column="2"
Margin="10 0 0 0"
Foreground="Red"
FontSize="14"
TextWrapping="Wrap"
Text="{Binding Message}" />
</Grid>
</DataTemplate>
<DataTemplate DataType="{x:Type models:EvenItem}">
<Grid ColumnDefinitions="Auto, Auto, *">
<TextBlock
Grid.Column="0"
Text="{Binding TimeStamp, StringFormat=\{0:T\}}"
FontWeight="Bold" />
<TextBlock
Grid.Column="1"
Margin="10 0 0 0"
Foreground="Blue"
FontSize="14"
FontWeight="Bold"
Text="{Binding Id}" />
<TextBlock
Grid.Column="2"
Margin="10 0 0 0"
Foreground="Blue"
FontSize="14"
TextWrapping="Wrap"
Text="{Binding Message}" />
</Grid>
</DataTemplate>
</ListBox.DataTemplates>
</ListBox>
</Grid>
</Window>