add listener for context menu
This commit is contained in:
parent
3456af5101
commit
3993a744b2
@ -10,6 +10,7 @@ using System.Linq;
|
|||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
using Avalonia.Controls.Selection;
|
||||||
using Tmds.DBus.Protocol;
|
using Tmds.DBus.Protocol;
|
||||||
|
|
||||||
namespace Presence.Desktop.ViewModels
|
namespace Presence.Desktop.ViewModels
|
||||||
@ -34,9 +35,10 @@ namespace Presence.Desktop.ViewModels
|
|||||||
get => _selectedGroupItem;
|
get => _selectedGroupItem;
|
||||||
set => this.RaiseAndSetIfChanged(ref _selectedGroupItem, value); }
|
set => this.RaiseAndSetIfChanged(ref _selectedGroupItem, value); }
|
||||||
|
|
||||||
|
private bool _MultipleSelected = false;
|
||||||
|
public bool MultipleSelected { get => _MultipleSelected; set => this.RaiseAndSetIfChanged(ref _MultipleSelected, value); }
|
||||||
|
public SelectionModel<UserPresenter> Selection { get; }
|
||||||
private GroupPresenter? _selectedGroupItem;
|
private GroupPresenter? _selectedGroupItem;
|
||||||
|
|
||||||
|
|
||||||
private IGroupUseCase _groupUseCase;
|
private IGroupUseCase _groupUseCase;
|
||||||
public ObservableCollection<UserPresenter> Users { get => _users;}
|
public ObservableCollection<UserPresenter> Users { get => _users;}
|
||||||
public ObservableCollection<UserPresenter> _users;
|
public ObservableCollection<UserPresenter> _users;
|
||||||
@ -52,6 +54,9 @@ namespace Presence.Desktop.ViewModels
|
|||||||
{ RefreshGroups();
|
{ RefreshGroups();
|
||||||
SetUsers();
|
SetUsers();
|
||||||
});
|
});
|
||||||
|
Selection = new SelectionModel<UserPresenter>();
|
||||||
|
Selection.SingleSelect = false;
|
||||||
|
Selection.SelectionChanged += SelectionChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetUsers()
|
private void SetUsers()
|
||||||
@ -93,6 +98,11 @@ namespace Presence.Desktop.ViewModels
|
|||||||
Console.WriteLine("clock");
|
Console.WriteLine("clock");
|
||||||
SelectedFile = await _SelectFileInteraction.Handle("Chose csv file");
|
SelectedFile = await _SelectFileInteraction.Handle("Chose csv file");
|
||||||
}
|
}
|
||||||
|
void SelectionChanged(object sender, SelectionModelSelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
MultipleSelected = Selection.SelectedItems.Count > 1;
|
||||||
|
}
|
||||||
|
|
||||||
public string? UrlPathSegment { get; }
|
public string? UrlPathSegment { get; }
|
||||||
public IScreen HostScreen { get; }
|
public IScreen HostScreen { get; }
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,14 @@
|
|||||||
<ComboBox/>
|
<ComboBox/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<Border>
|
<Border>
|
||||||
<ListBox Background="Bisque" ItemsSource="{Binding Users}">
|
<ListBox SelectionMode="Multiple" Selection="{Binding Selection}" Background="Bisque" ItemsSource="{Binding Users}">
|
||||||
|
<ListBox.ContextMenu>
|
||||||
|
<ContextMenu>
|
||||||
|
<MenuItem IsVisible="{Binding !MultipleSelected}" Header="Remove"/>
|
||||||
|
<MenuItem IsVisible="{Binding !MultipleSelected}" Header="Edit"/>
|
||||||
|
<MenuItem IsVisible="{Binding MultipleSelected}" Header="RemoveAll"></MenuItem>
|
||||||
|
</ContextMenu>
|
||||||
|
</ListBox.ContextMenu>
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
|
Loading…
Reference in New Issue
Block a user