presence/Presence.Desktop/Views/PresenceView.axaml.cs
2024-12-23 13:35:07 +03:00

31 lines
892 B
C#

using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI;
using Presence.Desktop.ViewModels;
using ReactiveUI;
using System.Linq;
namespace Presence.Desktop.Views;
public partial class PresenceView : ReactiveUserControl<PresenceViewModel>
{
public PresenceView()
{
this.WhenActivated(disposables => { });
AvaloniaXamlLoader.Load(this);
}
private void OnDataGridSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (this.DataContext is PresenceViewModel viewModel)
{
// Обновляем выделенные элементы в ViewModel
viewModel.SelectedItems.Clear();
foreach (var item in e.AddedItems.OfType<domain.Models.PresenceLocalEntity>())
{
viewModel.SelectedItems.Add(item);
}
}
}
}