33 lines
830 B
C#
33 lines
830 B
C#
using Avalonia.Controls;
|
|
using Avalonia.Markup.Xaml;
|
|
using DispenserUI.Models.DTO;
|
|
using DispenserUI.ViewModels.Setting;
|
|
|
|
namespace DispenserUI.Views.Setting;
|
|
|
|
public partial class SettingsView : UserControl
|
|
{
|
|
public SettingsView()
|
|
{
|
|
DataContext = ViewModel;
|
|
InitializeComponent();
|
|
}
|
|
|
|
public SettingsVM ViewModel { get; } = App.GetService<SettingsVM>();
|
|
|
|
private void InitializeComponent()
|
|
{
|
|
AvaloniaXamlLoader.Load(this);
|
|
}
|
|
|
|
|
|
private void TreeView_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
|
|
{
|
|
// 获取当前选中的项
|
|
var selectedItem = (sender as TreeView)?.SelectedItem;
|
|
|
|
if (selectedItem is TreeNode node)
|
|
// 这里处理选中的项,比如显示信息等
|
|
ViewModel.ClickedNode(node);
|
|
}
|
|
} |