Dispenser/DispenserUI/Views/Controls/ConsoleLog.axaml.cs

32 lines
822 B
C#
Raw Normal View History

2024-08-16 07:20:09 +00:00
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using DispenserCommon.Utils;
using DispenserUI.ViewModels.Components;
namespace DispenserUI.Views.Controls;
public partial class ConsoleLog : UserControl
{
public ConsoleLog()
{
DataContext = ViewModel;
InitializeComponent();
ConsoleViewer = this.FindControl<ScrollViewer>("ConsoleViewer");
ViewModel.Logs.CollectionChanged += (sender, args) => { ConsoleViewer!.ScrollToEnd(); };
}
public ConsoleLogVM ViewModel { get; } = ServiceLocator.GetService<ConsoleLogVM>();
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
protected override void OnLoaded(RoutedEventArgs e)
{
base.OnLoaded(e);
ViewModel.RenderLog();
}
}