-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMainWindow.xaml.cs
44 lines (36 loc) · 1.21 KB
/
MainWindow.xaml.cs
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
using Avalonia.Controls.Primitives;
using Avalonia.Interactivity;
namespace AvaloniaListBoxBug
{
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
public class MainWindow : Window
{
private readonly ListBox _messageList;
private ScrollViewer scroll;
public MainWindow()
{
InitializeComponent();
DataContext = new MainWindowViewModel();
_messageList = this.FindControl<ListBox>("MessageList");
_messageList.TemplateApplied += MessageListOnTemplateApplied;
}
private void MessageListOnTemplateApplied(object? sender, TemplateAppliedEventArgs e)
{
scroll = e.NameScope.Find<ScrollViewer>("PART_ScrollViewer");
scroll.ScrollChanged += ScrollOnScrollChanged;
}
private void ScrollOnScrollChanged(object? sender, ScrollChangedEventArgs e)
{
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
private void BtnScrollToEnd_Click(object sender, RoutedEventArgs e)
{
scroll.ScrollToEnd();
}
}
}