diff --git a/ModernKeePass/ViewModels/EntryDetailVm.cs b/ModernKeePass/ViewModels/EntryDetailVm.cs index efd1cd9..11e1f28 100644 --- a/ModernKeePass/ViewModels/EntryDetailVm.cs +++ b/ModernKeePass/ViewModels/EntryDetailVm.cs @@ -55,7 +55,7 @@ namespace ModernKeePass.ViewModels } } - public ObservableCollection History { get; private set; } + public ObservableCollection History { get; private set; } public ObservableCollection AdditionalFields { get; private set; } public ObservableCollection Attachments { get; private set; } @@ -275,8 +275,9 @@ namespace ModernKeePass.ViewModels { SelectedIndex = 0; _current = await _mediator.Send(new GetEntryQuery { Id = entryId }); + SetCurrentEntry(_current); _parent = await _mediator.Send(new GetGroupQuery { Id = _current.ParentGroupId }); - History = new ObservableCollection { _current }; + History = new ObservableCollection { _current }; foreach (var entry in _current.History.Skip(1)) { History.Add(entry); @@ -290,7 +291,7 @@ namespace ModernKeePass.ViewModels public async Task AddHistory() { - if (_isDirty && Database.IsOpen) await _mediator.Send(new AddHistoryCommand { Entry = History[0] }); + if (_isDirty && Database.IsOpen) await _mediator.Send(new AddHistoryCommand { Entry = History[0] as EntryVm }); } public void GoToGroup(string groupId) @@ -363,7 +364,7 @@ namespace ModernKeePass.ViewModels _resource.GetResourceValue("EntityDeleteCancelButton"), async isOk => { if (!isOk) return; - await _mediator.Send(new DeleteHistoryCommand { Entry = History[0], HistoryIndex = History.Count - SelectedIndex - 1 }); + await _mediator.Send(new DeleteHistoryCommand { Entry = History[0] as EntryVm, HistoryIndex = History.Count - SelectedIndex - 1 }); History.RemoveAt(SelectedIndex); }); } @@ -371,7 +372,7 @@ namespace ModernKeePass.ViewModels private async Task RestoreHistory() { - await _mediator.Send(new RestoreHistoryCommand { Entry = History[0], HistoryIndex = History.Count - SelectedIndex - 1 }); + await _mediator.Send(new RestoreHistoryCommand { Entry = History[0] as EntryVm, HistoryIndex = History.Count - SelectedIndex - 1 }); History.Insert(0, _current); } diff --git a/ModernKeePass/ViewModels/GroupDetailVm.cs b/ModernKeePass/ViewModels/GroupDetailVm.cs index 9da777c..cdeb2bc 100644 --- a/ModernKeePass/ViewModels/GroupDetailVm.cs +++ b/ModernKeePass/ViewModels/GroupDetailVm.cs @@ -38,7 +38,7 @@ namespace ModernKeePass.ViewModels { public ObservableCollection Entries { get; private set; } - public ObservableCollection Groups { get; private set; } + public ObservableCollection Groups { get; private set; } public bool IsNotRoot => Database.RootGroupId != _group.Id; @@ -144,7 +144,7 @@ namespace ModernKeePass.ViewModels Entries = new ObservableCollection(_group.Entries); Entries.CollectionChanged += Entries_CollectionChanged; - Groups = new ObservableCollection(_group.Groups); + Groups = new ObservableCollection(_group.Groups); Groups.CollectionChanged += Groups_CollectionChanged; } @@ -255,7 +255,7 @@ namespace ModernKeePass.ViewModels private async Task SortGroupsAsync() { await _mediator.Send(new SortGroupsCommand {Group = _group}); - Groups = new ObservableCollection(_group.Groups); + Groups = new ObservableCollection(_group.Groups); RaisePropertyChanged(nameof(Groups)); SaveCommand.RaiseCanExecuteChanged(); } diff --git a/ModernKeePass/ViewModels/ViewModelLocator.cs b/ModernKeePass/ViewModels/ViewModelLocator.cs index f5959ca..65cab32 100644 --- a/ModernKeePass/ViewModels/ViewModelLocator.cs +++ b/ModernKeePass/ViewModels/ViewModelLocator.cs @@ -15,6 +15,9 @@ using System; using CommonServiceLocator; using GalaSoft.MvvmLight.Ioc; +using Microsoft.Extensions.DependencyInjection; +using ModernKeePass.Domain.Interfaces; +using GalaSoft.MvvmLight; namespace ModernKeePass.ViewModels { @@ -29,6 +32,18 @@ namespace ModernKeePass.ViewModels /// public ViewModelLocator() { + if (ViewModelBase.IsInDesignModeStatic) + { + // Create design time view services and models + //SimpleIoc.Default.Register(); + } + else + { + // Create run time view services and models + //SimpleIoc.Default.Register();IDataService + SimpleIoc.Default.Register(() => App.Services.GetRequiredService()); + } + SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); diff --git a/ModernKeePass/Views/GroupDetailPage.xaml b/ModernKeePass/Views/GroupDetailPage.xaml index 2875e75..b533091 100644 --- a/ModernKeePass/Views/GroupDetailPage.xaml +++ b/ModernKeePass/Views/GroupDetailPage.xaml @@ -79,7 +79,7 @@ CanDragItems="{Binding IsEditMode}"> - + diff --git a/ModernKeePass/Views/MainPage.xaml b/ModernKeePass/Views/MainPage.xaml index 7b24eef..034a92f 100644 --- a/ModernKeePass/Views/MainPage.xaml +++ b/ModernKeePass/Views/MainPage.xaml @@ -57,6 +57,7 @@ Grid.Column="0" Grid.Row="1" x:Name="MenuListView" + ScrollViewer.VerticalScrollMode="Disabled" SelectionChanged="ListView_SelectionChanged" Background="{ThemeResource AppBarBackgroundThemeBrush}" ItemsSource="{Binding Source={StaticResource MenuItemsSource}}" diff --git a/ModernKeePass/Views/MainPageFrames/RecentDatabasesPage.xaml b/ModernKeePass/Views/MainPageFrames/RecentDatabasesPage.xaml index 82197f0..3a8ba98 100644 --- a/ModernKeePass/Views/MainPageFrames/RecentDatabasesPage.xaml +++ b/ModernKeePass/Views/MainPageFrames/RecentDatabasesPage.xaml @@ -9,6 +9,11 @@ mc:Ignorable="d" DataContext="{Binding Source={StaticResource Locator}, Path=Recent}"> + + + @@ -21,7 +26,7 @@ diff --git a/ModernKeePass/Views/UserControls/HamburgerMenuUserControl.xaml.cs b/ModernKeePass/Views/UserControls/HamburgerMenuUserControl.xaml.cs index 8c242ff..4d4d824 100644 --- a/ModernKeePass/Views/UserControls/HamburgerMenuUserControl.xaml.cs +++ b/ModernKeePass/Views/UserControls/HamburgerMenuUserControl.xaml.cs @@ -7,6 +7,7 @@ using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Input; using ModernKeePass.Application.Common.Interfaces; using ModernKeePass.Controls; +using System.Collections.ObjectModel; // The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236 @@ -62,18 +63,18 @@ namespace ModernKeePass.Views.UserControls typeof(HamburgerMenuUserControl), new PropertyMetadata(Visibility.Collapsed, (o, args) => { })); - public IEnumerable ItemsSource + public ObservableCollection ItemsSource { - get { return (IEnumerable)GetValue(ItemsSourceProperty); } + get { return (ObservableCollection)GetValue(ItemsSourceProperty); } set { SetValue(ItemsSourceProperty, value); } } public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.Register( nameof(ItemsSource), - typeof(IEnumerable), + typeof(ObservableCollection), typeof(HamburgerMenuUserControl), - new PropertyMetadata(new List(), (o, args) => { })); + new PropertyMetadata(new ObservableCollection(), (o, args) => { })); public object SelectedItem {