Sorting now works with code behind

This commit is contained in:
BONNEVILLE Geoffroy
2018-07-11 13:48:15 +02:00
parent 81ca11a955
commit 83d37d943f
4 changed files with 34 additions and 14 deletions

View File

@@ -450,4 +450,10 @@
<data name="TopMenuSortButton.Content" xml:space="preserve"> <data name="TopMenuSortButton.Content" xml:space="preserve">
<value>Sort</value> <value>Sort</value>
</data> </data>
<data name="TopMenuSortEntriesFlyout.Text" xml:space="preserve">
<value>Sort entries</value>
</data>
<data name="TopMenuSortGroupsFlyout.Text" xml:space="preserve">
<value>Sort groups</value>
</data>
</root> </root>

View File

@@ -450,4 +450,10 @@
<data name="TopMenuSortButton.Content" xml:space="preserve"> <data name="TopMenuSortButton.Content" xml:space="preserve">
<value>Trier</value> <value>Trier</value>
</data> </data>
<data name="TopMenuSortEntriesFlyout.Text" xml:space="preserve">
<value>Trier les entrées</value>
</data>
<data name="TopMenuSortGroupsFlyout.Text" xml:space="preserve">
<value>Trier les groupes</value>
</data>
</root> </root>

View File

@@ -21,13 +21,6 @@
</ToolTipService.ToolTip> </ToolTipService.ToolTip>
</SymbolIcon> </SymbolIcon>
</Button> </Button>
<ToggleButton Command="{Binding EditCommand, ElementName=UserControl}" IsChecked="{Binding IsEditButtonChecked, ElementName=UserControl, Mode=TwoWay}" Click="EditButton_Click" Style="{StaticResource NoBorderToggleButtonStyle}" Height="50">
<SymbolIcon Symbol="Edit">
<ToolTipService.ToolTip>
<ToolTip x:Uid="TopMenuEditButton" />
</ToolTipService.ToolTip>
</SymbolIcon>
</ToggleButton>
<Button Visibility="{Binding SortButtonVisibility, ElementName=UserControl}" Style="{StaticResource NoBorderButtonStyle}" Height="50"> <Button Visibility="{Binding SortButtonVisibility, ElementName=UserControl}" Style="{StaticResource NoBorderButtonStyle}" Height="50">
<SymbolIcon Symbol="Sort"> <SymbolIcon Symbol="Sort">
<ToolTipService.ToolTip> <ToolTipService.ToolTip>
@@ -35,12 +28,19 @@
</ToolTipService.ToolTip> </ToolTipService.ToolTip>
</SymbolIcon> </SymbolIcon>
<Button.Flyout> <Button.Flyout>
<MenuFlyout> <MenuFlyout Opening="SortFlyout_OnOpening">
<MenuFlyoutItem x:Uid="AppBarSortEntries" Command="{Binding SortEntriesCommand, ElementName=UserControl}" /> <MenuFlyoutItem x:Uid="AppBarSortEntries" x:Name="SortEntriesButtonFlyout" Command="{Binding SortEntriesCommand, ElementName=UserControl}" />
<MenuFlyoutItem x:Uid="AppBarSortGroups" Command="{Binding SortGroupsCommand, ElementName=UserControl}" /> <MenuFlyoutItem x:Uid="AppBarSortGroups" x:Name="SortGroupsButtonFlyout" Command="{Binding SortGroupsCommand, ElementName=UserControl}" />
</MenuFlyout> </MenuFlyout>
</Button.Flyout> </Button.Flyout>
</Button> </Button>
<ToggleButton Command="{Binding EditCommand, ElementName=UserControl}" IsChecked="{Binding IsEditButtonChecked, ElementName=UserControl, Mode=TwoWay}" Click="EditButton_Click" Style="{StaticResource NoBorderToggleButtonStyle}" Height="50">
<SymbolIcon Symbol="Edit">
<ToolTipService.ToolTip>
<ToolTip x:Uid="TopMenuEditButton" />
</ToolTipService.ToolTip>
</SymbolIcon>
</ToggleButton>
<Button Command="{Binding DeleteCommand, ElementName=UserControl}" IsEnabled="{Binding IsDeleteButtonEnabled, ElementName=UserControl}" Visibility="{Binding DeleteButtonVisibility, ElementName=UserControl}" Click="DeleteButton_Click" Style="{StaticResource NoBorderButtonStyle}" Height="50"> <Button Command="{Binding DeleteCommand, ElementName=UserControl}" IsEnabled="{Binding IsDeleteButtonEnabled, ElementName=UserControl}" Visibility="{Binding DeleteButtonVisibility, ElementName=UserControl}" Click="DeleteButton_Click" Style="{StaticResource NoBorderButtonStyle}" Height="50">
<SymbolIcon Symbol="Delete"> <SymbolIcon Symbol="Delete">
<ToolTipService.ToolTip> <ToolTipService.ToolTip>
@@ -52,13 +52,13 @@
<Button Visibility="{Binding MoreButtonVisibility, ElementName=UserControl}" Style="{StaticResource NoBorderButtonStyle}" Height="50"> <Button Visibility="{Binding MoreButtonVisibility, ElementName=UserControl}" Style="{StaticResource NoBorderButtonStyle}" Height="50">
<SymbolIcon Symbol="More" /> <SymbolIcon Symbol="More" />
<Button.Flyout> <Button.Flyout>
<MenuFlyout Opening="FlyoutBase_OnOpening"> <MenuFlyout Opening="OverflowFlyout_OnOpening">
<MenuFlyoutItem x:Uid="TopMenuRestoreFlyout" x:Name="RestoreFlyout" Command="{Binding RestoreCommand, ElementName=UserControl}" IsEnabled="{Binding IsRestoreButtonEnabled,ElementName=UserControl}" Click="RestoreButton_Click" Visibility="{Binding RestoreButtonVisibility, ElementName=UserControl}" /> <MenuFlyoutItem x:Uid="TopMenuRestoreFlyout" x:Name="RestoreFlyout" Command="{Binding RestoreCommand, ElementName=UserControl}" IsEnabled="{Binding IsRestoreButtonEnabled,ElementName=UserControl}" Click="RestoreButton_Click" Visibility="{Binding RestoreButtonVisibility, ElementName=UserControl}" />
<MenuFlyoutItem x:Uid="TopMenuSaveFlyout" Command="{Binding SaveCommand, ElementName=UserControl}" /> <MenuFlyoutItem x:Uid="TopMenuSaveFlyout" Command="{Binding SaveCommand, ElementName=UserControl}" />
<ToggleMenuFlyoutItem x:Uid="TopMenuEditFlyout" x:Name="EditFlyout" Command="{Binding EditCommand, ElementName=UserControl}" IsChecked="{Binding IsEditButtonChecked, ElementName=UserControl, Mode=TwoWay}" Click="EditButton_Click" /> <ToggleMenuFlyoutItem x:Uid="TopMenuEditFlyout" x:Name="EditFlyout" Command="{Binding EditCommand, ElementName=UserControl}" IsChecked="{Binding IsEditButtonChecked, ElementName=UserControl, Mode=TwoWay}" Click="EditButton_Click" />
<MenuFlyoutItem x:Uid="TopMenuDeleteFlyout" x:Name="DeleteFlyout" Command="{Binding DeleteCommand, ElementName=UserControl}" Click="DeleteButton_Click" Visibility="{Binding DeleteButtonVisibility, ElementName=UserControl}" IsEnabled="{Binding IsDeleteButtonEnabled, ElementName=UserControl}" /> <MenuFlyoutItem x:Uid="TopMenuDeleteFlyout" x:Name="DeleteFlyout" Command="{Binding DeleteCommand, ElementName=UserControl}" Click="DeleteButton_Click" Visibility="{Binding DeleteButtonVisibility, ElementName=UserControl}" IsEnabled="{Binding IsDeleteButtonEnabled, ElementName=UserControl}" />
<MenuFlyoutItem x:Uid="AppBarSortEntries" x:Name="SortEntriesFlyout" Command="{Binding SortEntriesCommand, ElementName=UserControl}" Visibility="{Binding SortButtonVisibility, ElementName=UserControl}" /> <MenuFlyoutItem x:Uid="TopMenuSortEntriesFlyout" x:Name="SortEntriesFlyout" Command="{Binding SortEntriesCommand, ElementName=UserControl}" Visibility="{Binding SortButtonVisibility, ElementName=UserControl}" />
<MenuFlyoutItem x:Uid="AppBarSortGroups" x:Name="SortGroupsFlyout" Command="{Binding SortGroupsCommand, ElementName=UserControl}" Visibility="{Binding SortButtonVisibility, ElementName=UserControl}" /> <MenuFlyoutItem x:Uid="TopMenuSortGroupsFlyout" x:Name="SortGroupsFlyout" Command="{Binding SortGroupsCommand, ElementName=UserControl}" Visibility="{Binding SortButtonVisibility, ElementName=UserControl}" />
</MenuFlyout> </MenuFlyout>
</Button.Flyout> </Button.Flyout>
</Button> </Button>

View File

@@ -209,7 +209,7 @@ namespace ModernKeePass.Views.UserControls
RestoreButtonClick?.Invoke(sender, e); RestoreButtonClick?.Invoke(sender, e);
} }
private void FlyoutBase_OnOpening(object sender, object e) private void OverflowFlyout_OnOpening(object sender, object e)
{ {
DeleteFlyout.IsEnabled = IsDeleteButtonEnabled; DeleteFlyout.IsEnabled = IsDeleteButtonEnabled;
DeleteFlyout.Visibility = DeleteButtonVisibility; DeleteFlyout.Visibility = DeleteButtonVisibility;
@@ -221,6 +221,14 @@ namespace ModernKeePass.Views.UserControls
SortEntriesFlyout.Visibility = SortButtonVisibility; SortEntriesFlyout.Visibility = SortButtonVisibility;
SortGroupsFlyout.Visibility = SortButtonVisibility; SortGroupsFlyout.Visibility = SortButtonVisibility;
SortEntriesFlyout.Command = SortEntriesCommand;
SortGroupsFlyout.Command = SortGroupsCommand;
}
private void SortFlyout_OnOpening(object sender, object e)
{
SortEntriesButtonFlyout.Command = SortEntriesCommand;
SortGroupsButtonFlyout.Command = SortGroupsCommand;
} }
} }
} }