mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Opening Databases now use a Messenger service
This commit is contained in:
@@ -3,7 +3,13 @@ using Windows.Storage.AccessCache;
|
||||
using Windows.Storage.Pickers;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
using GalaSoft.MvvmLight.Messaging;
|
||||
using GalaSoft.MvvmLight.Views;
|
||||
using Messages;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ModernKeePass.Common;
|
||||
using ModernKeePass.Domain.Dtos;
|
||||
using ModernKeePass.Models;
|
||||
using ModernKeePass.ViewModels;
|
||||
|
||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
@@ -15,11 +21,24 @@ namespace ModernKeePass.Views
|
||||
/// </summary>
|
||||
public sealed partial class OpenDatabasePage
|
||||
{
|
||||
public OpenVm Model => (OpenVm)DataContext;
|
||||
private readonly INavigationService _navigation;
|
||||
private OpenVm Model => (OpenVm)Resources["ViewModel"];
|
||||
|
||||
public OpenDatabasePage()
|
||||
public OpenDatabasePage(): this(
|
||||
App.Services.GetRequiredService<INavigationService>(),
|
||||
App.Services.GetRequiredService<IMessenger>()) { }
|
||||
|
||||
public OpenDatabasePage(INavigationService navigation, IMessenger messenger)
|
||||
{
|
||||
_navigation = navigation;
|
||||
InitializeComponent();
|
||||
|
||||
messenger.Register<DatabaseOpenedMessage>(this, NavigateToPage);
|
||||
}
|
||||
|
||||
private void NavigateToPage(DatabaseOpenedMessage message)
|
||||
{
|
||||
_navigation.NavigateTo(Constants.Navigation.GroupPage, new NavigationItem { Id = message.RootGroupId });
|
||||
}
|
||||
|
||||
protected override async void OnNavigatedTo(NavigationEventArgs e)
|
||||
|
Reference in New Issue
Block a user