mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
All VMs use viewmodellocator
This commit is contained in:
@@ -12,7 +12,8 @@
|
||||
xmlns:userControls="using:ModernKeePass.Views.UserControls"
|
||||
x:Class="ModernKeePass.Views.EntryDetailPage"
|
||||
mc:Ignorable="d"
|
||||
SizeChanged="EntryDetailPage_OnSizeChanged">
|
||||
SizeChanged="EntryDetailPage_OnSizeChanged"
|
||||
DataContext="{Binding Source={StaticResource Locator}, Path=Entry}">
|
||||
<Page.Resources>
|
||||
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
|
||||
<converters:InverseBooleanToVisibilityConverter x:Key="InverseBooleanToVisibilityConverter" />
|
||||
@@ -369,9 +370,6 @@
|
||||
</Setter>
|
||||
</Style>
|
||||
</Page.Resources>
|
||||
<Page.DataContext>
|
||||
<viewModels:EntryDetailVm />
|
||||
</Page.DataContext>
|
||||
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
<Grid.ChildrenTransitions>
|
||||
<TransitionCollection>
|
||||
|
@@ -27,7 +27,8 @@ namespace ModernKeePass.Views
|
||||
var args = e.Parameter as NavigationItem;
|
||||
if (args != null)
|
||||
{
|
||||
DataContext = new EntryDetailVm(args.Id) { IsEditMode = args.IsNew };
|
||||
await Model.Initialize(args.Id);
|
||||
Model.IsEditMode = args.IsNew;
|
||||
if (args.IsNew) await Model.GeneratePassword();
|
||||
}
|
||||
}
|
||||
|
@@ -3,25 +3,21 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:viewModels="using:ModernKeePass.ViewModels"
|
||||
xmlns:converters="using:ModernKeePass.Converters"
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
|
||||
xmlns:actions="using:ModernKeePass.Actions"
|
||||
xmlns:userControls="using:ModernKeePass.Views.UserControls"
|
||||
x:Name="PageRoot"
|
||||
x:Class="ModernKeePass.Views.GroupDetailPage"
|
||||
mc:Ignorable="d"
|
||||
SizeChanged="GroupDetailPage_OnSizeChanged">
|
||||
SizeChanged="GroupDetailPage_OnSizeChanged"
|
||||
DataContext="{Binding Source={StaticResource Locator}, Path=Group}">
|
||||
<Page.Resources>
|
||||
<converters:ColorToBrushConverter x:Key="ColorToBrushConverter"/>
|
||||
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
||||
<converters:InverseBooleanToVisibilityConverter x:Key="InverseBooleanToVisibilityConverter"/>
|
||||
<converters:IconToSymbolConverter x:Key="IconToSymbolConverter"/>
|
||||
</Page.Resources>
|
||||
<Page.DataContext>
|
||||
<viewModels:GroupDetailVm />
|
||||
</Page.DataContext>
|
||||
<Grid>
|
||||
<Grid.Resources>
|
||||
<CollectionViewSource
|
||||
|
@@ -7,7 +7,6 @@ using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
using GalaSoft.MvvmLight.Views;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Application.Entry.Models;
|
||||
using ModernKeePass.Common;
|
||||
using ModernKeePass.Models;
|
||||
@@ -23,26 +22,27 @@ namespace ModernKeePass.Views
|
||||
/// </summary>
|
||||
public sealed partial class GroupDetailPage
|
||||
{
|
||||
private readonly IResourceProxy _resource;
|
||||
private readonly INavigationService _navigation;
|
||||
|
||||
public GroupDetailVm Model => (GroupDetailVm)DataContext;
|
||||
|
||||
public GroupDetailPage(): this (App.Services.GetRequiredService<IResourceProxy>(), App.Services.GetRequiredService<INavigationService>()) { }
|
||||
public GroupDetailPage(IResourceProxy resource, INavigationService navigation)
|
||||
public GroupDetailPage(): this (App.Services.GetRequiredService<INavigationService>()) { }
|
||||
public GroupDetailPage(INavigationService navigation)
|
||||
{
|
||||
InitializeComponent();
|
||||
_resource = resource;
|
||||
_navigation = navigation;
|
||||
}
|
||||
|
||||
#region NavigationHelper registration
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
protected override async void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
var navigationItem = e.Parameter as NavigationItem;
|
||||
if (navigationItem != null)
|
||||
DataContext = new GroupDetailVm(navigationItem.Id) { IsEditMode = navigationItem.IsNew };
|
||||
{
|
||||
await Model.Initialize(navigationItem.Id);
|
||||
Model.IsEditMode = navigationItem.IsNew;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@@ -3,12 +3,12 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:viewModels="using:ModernKeePass.ViewModels"
|
||||
xmlns:controls="using:ModernKeePass.Controls"
|
||||
xmlns:basePages="using:ModernKeePass.Views.BasePages"
|
||||
x:Class="ModernKeePass.Views.MainPage"
|
||||
x:Name="PageRoot"
|
||||
mc:Ignorable="d">
|
||||
mc:Ignorable="d"
|
||||
DataContext="{Binding Source={StaticResource Locator}, Path=Main}">
|
||||
<Page.Resources>
|
||||
<CollectionViewSource
|
||||
x:Name="MenuItemsSource"
|
||||
@@ -19,9 +19,6 @@
|
||||
<Page.Background>
|
||||
<StaticResource ResourceKey="ApplicationPageBackgroundThemeBrush"/>
|
||||
</Page.Background>
|
||||
<Page.DataContext>
|
||||
<viewModels:MainVm />
|
||||
</Page.DataContext>
|
||||
|
||||
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
|
||||
<Grid.ChildrenTransitions>
|
||||
|
@@ -37,11 +37,11 @@ namespace ModernKeePass.Views
|
||||
else selectedItem.Destination.Navigate(selectedItem.PageType, selectedItem.Parameter);
|
||||
}
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
protected override async void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
var file = e.Parameter as FileInfo;
|
||||
DataContext = new MainVm(Frame, MenuFrame, file);
|
||||
await Model.Initialize(Frame, MenuFrame, file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user