mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Finally a workaround the stupid CommandBar DataContext issues
Delete and Restore actions now work as intended Renamed styles folder
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using System.Windows.Input;
|
||||
using Windows.UI.Xaml;
|
||||
using Microsoft.Xaml.Interactivity;
|
||||
using ModernKeePass.Common;
|
||||
using ModernKeePass.Interfaces;
|
||||
@@ -20,14 +20,14 @@ namespace ModernKeePass.Actions
|
||||
DependencyProperty.Register("Entity", typeof(IPwEntity), typeof(DeleteEntityAction),
|
||||
new PropertyMetadata(null));
|
||||
|
||||
public Frame Frame
|
||||
public ICommand Command
|
||||
{
|
||||
get { return (Frame)GetValue(FrameProperty); }
|
||||
set { SetValue(FrameProperty, value); }
|
||||
get { return (ICommand)GetValue(CommandProperty); }
|
||||
set { SetValue(CommandProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty FrameProperty =
|
||||
DependencyProperty.Register("Frame", typeof(Frame), typeof(DeleteEntityAction),
|
||||
public static readonly DependencyProperty CommandProperty =
|
||||
DependencyProperty.Register("Command", typeof(ICommand), typeof(DeleteEntityAction),
|
||||
new PropertyMetadata(null));
|
||||
|
||||
public object Execute(object sender, object parameter)
|
||||
@@ -45,7 +45,7 @@ namespace ModernKeePass.Actions
|
||||
{
|
||||
ToastNotificationHelper.ShowMovedToast(Entity, resource.GetResourceValue("EntityDeleting"), text);
|
||||
Entity.MarkForDelete(resource.GetResourceValue("RecycleBinTitle"));
|
||||
if (Frame.CanGoBack) Frame.GoBack();
|
||||
Command.Execute(null);
|
||||
}, null).GetAwaiter();
|
||||
|
||||
return null;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using System.Windows.Input;
|
||||
using Windows.UI.Xaml;
|
||||
using Microsoft.Xaml.Interactivity;
|
||||
using ModernKeePass.Common;
|
||||
using ModernKeePass.Interfaces;
|
||||
@@ -19,15 +19,15 @@ namespace ModernKeePass.Actions
|
||||
public static readonly DependencyProperty EntityProperty =
|
||||
DependencyProperty.Register("Entity", typeof(IPwEntity), typeof(RestoreEntityAction),
|
||||
new PropertyMetadata(null));
|
||||
|
||||
public Frame Frame
|
||||
|
||||
public ICommand Command
|
||||
{
|
||||
get { return (Frame)GetValue(FrameProperty); }
|
||||
set { SetValue(FrameProperty, value); }
|
||||
get { return (ICommand)GetValue(CommandProperty); }
|
||||
set { SetValue(CommandProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty FrameProperty =
|
||||
DependencyProperty.Register("Frame", typeof(Frame), typeof(RestoreEntityAction),
|
||||
public static readonly DependencyProperty CommandProperty =
|
||||
DependencyProperty.Register("Command", typeof(ICommand), typeof(RestoreEntityAction),
|
||||
new PropertyMetadata(null));
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace ModernKeePass.Actions
|
||||
|
||||
ToastNotificationHelper.ShowMovedToast(Entity, resource.GetResourceValue("EntityRestoredTitle"),
|
||||
resource.GetResourceValue($"{type}Restored"));
|
||||
if (Frame.CanGoBack) Frame.GoBack();
|
||||
Command.Execute(null);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@@ -6,12 +6,12 @@
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Styles/Colors.xaml" />
|
||||
<ResourceDictionary Source="Styles/TextBoxWithButtonStyle.xaml" />
|
||||
<ResourceDictionary Source="Styles/HamburgerButtonStyle.xaml" />
|
||||
<ResourceDictionary Source="Styles/ListViewLeftIndicatorStyle.xaml" />
|
||||
<ResourceDictionary Source="Styles/NoBorderButtonStyle.xaml" />
|
||||
<ResourceDictionary Source="Styles/Styles.xaml" />
|
||||
<ResourceDictionary Source="ResourceDictionaries/Colors.xaml" />
|
||||
<ResourceDictionary Source="ResourceDictionaries/TextBoxWithButtonStyle.xaml" />
|
||||
<ResourceDictionary Source="ResourceDictionaries/HamburgerButtonStyle.xaml" />
|
||||
<ResourceDictionary Source="ResourceDictionaries/ListViewLeftIndicatorStyle.xaml" />
|
||||
<ResourceDictionary Source="ResourceDictionaries/NoBorderButtonStyle.xaml" />
|
||||
<ResourceDictionary Source="ResourceDictionaries/Styles.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
|
@@ -23,6 +23,7 @@ namespace ModernKeePass.Interfaces
|
||||
/// Restore ViewModel
|
||||
/// </summary>
|
||||
ICommand UndoDeleteCommand { get; }
|
||||
ICommand GoBackCommand { get; set; }
|
||||
/// <summary>
|
||||
/// Move a entity to the destination group
|
||||
/// </summary>
|
||||
|
@@ -254,7 +254,7 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="Styles\Colors.xaml">
|
||||
<Page Include="ResourceDictionaries\Colors.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
@@ -331,27 +331,27 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Styles\HamburgerButtonStyle.xaml">
|
||||
<Page Include="ResourceDictionaries\HamburgerButtonStyle.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Page>
|
||||
<Page Include="Styles\ListViewLeftIndicatorStyle.xaml">
|
||||
<Page Include="ResourceDictionaries\ListViewLeftIndicatorStyle.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Page>
|
||||
<Page Include="Styles\NoBorderButtonStyle.xaml">
|
||||
<Page Include="ResourceDictionaries\NoBorderButtonStyle.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Page>
|
||||
<Page Include="Styles\Styles.xaml">
|
||||
<Page Include="ResourceDictionaries\Styles.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Page>
|
||||
<Page Include="Styles\TextBoxWithButtonStyle.xaml">
|
||||
<Page Include="ResourceDictionaries\TextBoxWithButtonStyle.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
|
@@ -163,6 +163,7 @@ namespace ModernKeePass.ViewModels
|
||||
public ICommand SaveCommand { get; }
|
||||
public ICommand GeneratePasswordCommand { get; }
|
||||
public ICommand UndoDeleteCommand { get; }
|
||||
public ICommand GoBackCommand { get; set; }
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
|
@@ -113,6 +113,7 @@ namespace ModernKeePass.ViewModels
|
||||
public ICommand SortEntriesCommand { get; }
|
||||
public ICommand SortGroupsCommand { get; }
|
||||
public ICommand UndoDeleteCommand { get; }
|
||||
public ICommand GoBackCommand { get; set; }
|
||||
|
||||
private readonly PwGroup _pwGroup;
|
||||
private readonly IDatabaseService _database;
|
||||
|
@@ -273,44 +273,48 @@
|
||||
Grid.Row="1"
|
||||
Background="{TemplateBinding Background}"
|
||||
Margin="{TemplateBinding BorderThickness}"
|
||||
Grid.ColumnSpan="3"
|
||||
Grid.RowSpan="1"/>
|
||||
Grid.ColumnSpan="3"/>
|
||||
<Border x:Name="BorderElement"
|
||||
Grid.Row="1"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Grid.ColumnSpan="3"/>
|
||||
<ContentPresenter
|
||||
x:Name="HeaderContentPresenter"
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Foreground="{ThemeResource TextBoxForegroundHeaderThemeBrush}"
|
||||
Margin="0,4,0,4"
|
||||
Grid.ColumnSpan="3"
|
||||
Grid.RowSpan="1"/>
|
||||
<ContentPresenter x:Name="HeaderContentPresenter"
|
||||
Grid.Row="0"
|
||||
Foreground="{ThemeResource TextBoxForegroundHeaderThemeBrush}"
|
||||
Margin="0,4,0,4"
|
||||
Grid.ColumnSpan="3"
|
||||
Content="{TemplateBinding Header}"
|
||||
ContentTemplate="{TemplateBinding HeaderTemplate}"
|
||||
FontWeight="Semilight" />
|
||||
Content="{TemplateBinding Header}"
|
||||
ContentTemplate="{TemplateBinding HeaderTemplate}"
|
||||
FontWeight="Semilight" />
|
||||
<ScrollViewer x:Name="ContentElement"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}"
|
||||
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
|
||||
VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}"
|
||||
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
|
||||
IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}"
|
||||
IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}"
|
||||
Margin="{TemplateBinding BorderThickness}"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
IsTabStop="False"
|
||||
ZoomMode="Disabled"
|
||||
AutomationProperties.AccessibilityView="Raw"/>
|
||||
<ContentControl
|
||||
x:Name="PlaceholderTextContentPresenter"
|
||||
Grid.Row="1"
|
||||
HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}"
|
||||
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
|
||||
VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}"
|
||||
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
|
||||
IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}"
|
||||
IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}"
|
||||
Margin="{TemplateBinding BorderThickness}"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
IsTabStop="False"
|
||||
ZoomMode="Disabled"
|
||||
AutomationProperties.AccessibilityView="Raw"/>
|
||||
<ContentControl x:Name="PlaceholderTextContentPresenter"
|
||||
Grid.Row="1"
|
||||
Foreground="{ThemeResource TextBoxPlaceholderTextThemeBrush}"
|
||||
Margin="{TemplateBinding BorderThickness}"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
IsTabStop="False"
|
||||
Grid.ColumnSpan="3"
|
||||
Content="{TemplateBinding PlaceholderText}"
|
||||
IsHitTestVisible="False"/>
|
||||
Grid.Column="0"
|
||||
Foreground="{ThemeResource TextBoxPlaceholderTextThemeBrush}"
|
||||
Margin="{TemplateBinding BorderThickness}"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
IsTabStop="False"
|
||||
Grid.ColumnSpan="3"
|
||||
Content="{TemplateBinding PlaceholderText}"
|
||||
IsHitTestVisible="False"/>
|
||||
<Button x:Name="RevealButton"
|
||||
Grid.Row="1"
|
||||
Style="{StaticResource RevealButtonStyle}"
|
||||
@@ -367,9 +371,9 @@
|
||||
</Setter>
|
||||
</Style>
|
||||
</Page.Resources>
|
||||
<Page.DataContext>
|
||||
<!--<Page.DataContext>
|
||||
<viewModels:EntryVm />
|
||||
</Page.DataContext>
|
||||
</Page.DataContext>-->
|
||||
<Page.BottomAppBar>
|
||||
<CommandBar x:Name="CommandBar" VerticalAlignment="Center">
|
||||
<CommandBar.SecondaryCommands>
|
||||
@@ -380,7 +384,7 @@
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</AppBarButton>
|
||||
<AppBarButton Icon="Save" x:Uid="AppBarSave" Command="{Binding SaveCommand}">
|
||||
<AppBarButton Icon="Save" x:Uid="AppBarSave" Command="{Binding Path=SaveCommand}">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Click">
|
||||
<core:ChangePropertyAction TargetObject="{Binding ElementName=CommandBar}" PropertyName="IsOpen" Value="False" />
|
||||
@@ -405,14 +409,14 @@
|
||||
<AppBarButton Icon="Undo" x:Uid="AppBarRestore" Visibility="{Binding ParentGroup.IsSelected, Converter={StaticResource BooleanToVisibilityConverter}}" IsEnabled="{Binding PreviousGroup, Converter={StaticResource NullToBooleanConverter}}" Command="{Binding UndoDeleteCommand}">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Click">
|
||||
<actions:RestoreEntityAction Entity="{Binding}" Frame="{Binding Frame, ElementName=PageRoot}" />
|
||||
<actions:RestoreEntityAction Entity="{Binding}" Command="{Binding GoBackCommand}" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</AppBarButton>
|
||||
<AppBarButton Icon="Delete" x:Uid="AppBarDelete">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Click">
|
||||
<actions:DeleteEntityAction Entity="{Binding}" Frame="{Binding Frame, ElementName=PageRoot}" />
|
||||
<actions:DeleteEntityAction Entity="{Binding}" Command="{Binding GoBackCommand}" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</AppBarButton>
|
||||
|
@@ -2,7 +2,6 @@
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
using ModernKeePass.Common;
|
||||
using ModernKeePass.Services;
|
||||
using ModernKeePass.ViewModels;
|
||||
|
||||
// Pour en savoir plus sur le modèle d'élément Page Détail de l'élément, consultez la page http://go.microsoft.com/fwlink/?LinkId=234232
|
||||
@@ -28,7 +27,7 @@ namespace ModernKeePass.Views
|
||||
InitializeComponent();
|
||||
NavigationHelper = new NavigationHelper(this);
|
||||
}
|
||||
|
||||
|
||||
#region Inscription de NavigationHelper
|
||||
|
||||
/// Les méthodes fournies dans cette section sont utilisées simplement pour permettre
|
||||
@@ -45,6 +44,7 @@ namespace ModernKeePass.Views
|
||||
NavigationHelper.OnNavigatedTo(e);
|
||||
if (!(e.Parameter is EntryVm)) return;
|
||||
DataContext = (EntryVm)e.Parameter;
|
||||
Model.GoBackCommand = NavigationHelper.GoBackCommand;
|
||||
}
|
||||
|
||||
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
||||
|
@@ -66,14 +66,14 @@
|
||||
<AppBarButton Icon="Undo" x:Uid="AppBarRestore" Visibility="{Binding ShowRestore, Converter={StaticResource BooleanToVisibilityConverter}}" IsEnabled="{Binding PreviousGroup, Converter={StaticResource NullToBooleanConverter}}" Command="{Binding UndoDeleteCommand}">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Click">
|
||||
<actions:RestoreEntityAction Entity="{Binding}" Frame="{Binding Frame, ElementName=PageRoot}" />
|
||||
<actions:RestoreEntityAction Entity="{Binding}" Command="{Binding GoBackCommand}" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</AppBarButton>
|
||||
<AppBarButton Icon="Delete" x:Uid="AppBarDelete" IsEnabled="{Binding IsNotRoot}" Visibility="{Binding IsSelected, Converter={StaticResource InverseBooleanToVisibilityConverter}}">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:EventTriggerBehavior EventName="Click">
|
||||
<actions:DeleteEntityAction Entity="{Binding}" Frame="{Binding Frame, ElementName=PageRoot}" />
|
||||
<actions:DeleteEntityAction Entity="{Binding}" Command="{Binding GoBackCommand}" />
|
||||
</core:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</AppBarButton>
|
||||
|
@@ -7,7 +7,6 @@ using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
using ModernKeePass.Common;
|
||||
using ModernKeePass.Events;
|
||||
using ModernKeePass.Services;
|
||||
using ModernKeePass.ViewModels;
|
||||
|
||||
// The Group Detail Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234229
|
||||
@@ -57,6 +56,7 @@ namespace ModernKeePass.Views
|
||||
if (vm != null)
|
||||
DataContext = vm;
|
||||
}
|
||||
Model.GoBackCommand = NavigationHelper.GoBackCommand;
|
||||
}
|
||||
|
||||
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
||||
|
Reference in New Issue
Block a user