mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Finally a nicer looking and working TextBoxWithButton (inspired from the SearchButton)
SearchBox field style improved
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows.Input;
|
||||
using Windows.Storage.Streams;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using ModernKeePass.ViewModels;
|
||||
|
||||
// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236
|
||||
|
||||
@@ -8,6 +13,8 @@ namespace ModernKeePass.Views.UserControls
|
||||
{
|
||||
public sealed partial class TopMenuUserControl
|
||||
{
|
||||
public TopMenuVm Model => (TopMenuVm)StackPanel.DataContext;
|
||||
|
||||
public ICommand SaveCommand
|
||||
{
|
||||
get { return (ICommand)GetValue(SaveCommandProperty); }
|
||||
@@ -44,18 +51,18 @@ namespace ModernKeePass.Views.UserControls
|
||||
typeof(TopMenuUserControl),
|
||||
new PropertyMetadata(null, (o, args) => { }));
|
||||
|
||||
public ICommand MoveCommand
|
||||
public RelayCommand<string> MoveCommand
|
||||
{
|
||||
get { return (ICommand)GetValue(MoveCommandProperty); }
|
||||
get { return (RelayCommand<string>)GetValue(MoveCommandProperty); }
|
||||
set { SetValue(MoveCommandProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty MoveCommandProperty =
|
||||
DependencyProperty.Register(
|
||||
nameof(MoveCommand),
|
||||
typeof(ICommand),
|
||||
typeof(RelayCommand<string>),
|
||||
typeof(TopMenuUserControl),
|
||||
new PropertyMetadata(null, (o, args) => { }));
|
||||
|
||||
|
||||
public ICommand RestoreCommand
|
||||
{
|
||||
get { return (ICommand)GetValue(RestoreCommandProperty); }
|
||||
@@ -114,7 +121,7 @@ namespace ModernKeePass.Views.UserControls
|
||||
nameof(MoveButtonVisibility),
|
||||
typeof(Visibility),
|
||||
typeof(TopMenuUserControl),
|
||||
new PropertyMetadata(Visibility.Collapsed, (o, args) => { }));
|
||||
new PropertyMetadata(Visibility.Visible, (o, args) => { }));
|
||||
|
||||
public Visibility RestoreButtonVisibility
|
||||
{
|
||||
@@ -198,6 +205,20 @@ namespace ModernKeePass.Views.UserControls
|
||||
SortEntriesButtonFlyout.Command = SortEntriesCommand;
|
||||
SortGroupsButtonFlyout.Command = SortGroupsCommand;
|
||||
}
|
||||
|
||||
private void SearchBox_OnSuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
|
||||
{
|
||||
var imageUri = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appdata://Assets/ModernKeePass-SmallLogo.scale-80.png"));
|
||||
foreach (var group in Model.Groups.Where(g => g.Title.IndexOf(args.QueryText, StringComparison.OrdinalIgnoreCase) >= 0))
|
||||
{
|
||||
args.Request.SearchSuggestionCollection.AppendResultSuggestion(group.Title, group.ParentGroupName, group.Id, imageUri, string.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
private void SearchBox_OnResultSuggestionChosen(SearchBox sender, SearchBoxResultSuggestionChosenEventArgs args)
|
||||
{
|
||||
Model.SelectedDestinationGroup = args.Tag;
|
||||
MoveCommand.RaiseCanExecuteChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user