mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Additional fields Add, Update and Delete work (too well)
SelectableListView works when programmatically setting selection
This commit is contained in:
37
WinAppCommon/ViewModels/Items/FieldVm.cs
Normal file
37
WinAppCommon/ViewModels/Items/FieldVm.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using GalaSoft.MvvmLight;
|
||||
using Messages;
|
||||
|
||||
namespace ModernKeePass.ViewModels.ListItems
|
||||
{
|
||||
public class FieldVm: ViewModelBase
|
||||
{
|
||||
private string _name;
|
||||
private string _value;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set
|
||||
{
|
||||
MessengerInstance.Send(new EntryFieldNameChangedMessage { OldName = Name, NewName = value, Value = Value });
|
||||
Set(nameof(Name), ref _name, value);
|
||||
}
|
||||
}
|
||||
|
||||
public string Value
|
||||
{
|
||||
get { return _value; }
|
||||
set
|
||||
{
|
||||
MessengerInstance.Send(new EntryFieldValueChangedMessage { FieldName = Name, FieldValue = value });
|
||||
Set(nameof(Value), ref _value, value);
|
||||
}
|
||||
}
|
||||
|
||||
public FieldVm(string fieldName, string fieldValue)
|
||||
{
|
||||
_name = fieldName;
|
||||
_value = fieldValue;
|
||||
}
|
||||
}
|
||||
}
|
@@ -13,6 +13,7 @@ namespace ModernKeePass.ViewModels
|
||||
{
|
||||
private readonly IRecentProxy _recent;
|
||||
private ObservableCollection<RecentItemVm> _recentItems;
|
||||
private int _selectedIndex;
|
||||
|
||||
public ObservableCollection<RecentItemVm> RecentItems
|
||||
{
|
||||
@@ -21,7 +22,13 @@ namespace ModernKeePass.ViewModels
|
||||
}
|
||||
|
||||
public ICommand ClearAllCommand { get; }
|
||||
|
||||
|
||||
public int SelectedIndex
|
||||
{
|
||||
get { return _selectedIndex; }
|
||||
set { Set(() => SelectedIndex, ref _selectedIndex, value); }
|
||||
}
|
||||
|
||||
public RecentVm(IRecentProxy recent)
|
||||
{
|
||||
_recent = recent;
|
||||
@@ -34,6 +41,7 @@ namespace ModernKeePass.ViewModels
|
||||
{
|
||||
var recentItems = _recent.GetAll().Select(r => new RecentItemVm(r));
|
||||
RecentItems = new ObservableCollection<RecentItemVm>(recentItems);
|
||||
if (RecentItems.Any()) SelectedIndex = 0;
|
||||
}
|
||||
|
||||
private void ClearAll()
|
||||
|
Reference in New Issue
Block a user