Add KeyBindingBehavior

This commit is contained in:
TheXamlGuy
2024-04-22 22:30:57 +01:00
parent 3e0798f867
commit 79735be033
11 changed files with 82 additions and 72 deletions
-38
View File
@@ -17,47 +17,9 @@
<Style Selector="ui|SettingsExpander /template/ Expander#Expander ToggleButton">
<Setter Property="CornerRadius" Value="{DynamicResource OverlayCornerRadius}" />
</Style>
<Style Selector="Button">
<Setter Property="CornerRadius" Value="{DynamicResource OverlayCornerRadius}" />
</Style>
<Style Selector="TextBox">
<Setter Property="CornerRadius" Value="0" />
<Setter Property="BorderThickness" Value="0 0 0 2" />
<Style Selector="^:focus">
<Style Selector="^ /template/ Border#PART_BorderElement">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderThickness" Value="0 0 0 2" />
</Style>
</Style>
</Style>
<Style Selector="OverlayPopupHost">
<Setter Property="Template">
<ControlTemplate>
<!-- Do not forget to update Templated_Control_With_Popup_In_Template_Should_Set_TemplatedParent test -->
<LayoutTransformControl LayoutTransform="{TemplateBinding Transform}">
<VisualLayerManager IsPopup="True">
<LayoutTransformControl>
<LayoutTransformControl.LayoutTransform>
<ScaleTransform ScaleX="1.4" ScaleY="1.4" />
</LayoutTransformControl.LayoutTransform>
<ContentPresenter
Name="PART_ContentPresenter"
Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}" />
</LayoutTransformControl>
</VisualLayerManager>
</LayoutTransformControl>
</ControlTemplate>
</Setter>
</Style>
</Application.Styles>
<Application.Resources>
<Thickness x:Key="TextControlThemePadding">0,5,6,6</Thickness>
<FontFamily x:Key="SymbolFontFamily">avares://HyperX.Launcher.Avalonia/Assets/SegoeIcons.ttf#Segoe Fluent Icons</FontFamily>
<StaticResource x:Key="TextControlBackground" ResourceKey="ControlFillColorTransparentBrush" />
<StaticResource x:Key="TextControlBackgroundPointerOver" ResourceKey="ControlFillColorTransparentBrush" />
<x:Double x:Key="SettingsExpanderItemAdaptiveWidthTrigger">0</x:Double>
<Thickness x:Key="SettingsExpanderItemBottomFooterMargin">0,8,0,0</Thickness>
</Application.Resources>
+1 -2
View File
@@ -36,8 +36,7 @@ public partial class App : Application
services.AddTemplate<MainViewModel, MainView>("Main");
services.AddHandler<MainViewModelHandler>();
services.AddConfiguration<VaultConfiguration>(args => args.Name = "Personal",
$"{nameof(VaultConfiguration)}:Personal");
services.AddConfiguration<VaultConfiguration>(args => args.Name = "Personal", "Vault:Personal");
})
.Build();
+15 -9
View File
@@ -1,9 +1,15 @@
<Window xmlns="https://github.com/avaloniaui"
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"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Bitvault.Avalonia.LockView"
Title="LockView">
Welcome to Avalonia!
</Window>
<UserControl
x:Class="Bitvault.Avalonia.LockView"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBox
Width="300"
Classes="revealPasswordButton"
PasswordChar="&#x25CF;">
<TextBox.KeyBindings>
<KeyBinding Gesture="Enter" />
</TextBox.KeyBindings>
</TextBox>
</StackPanel>
</UserControl>
+4 -8
View File
@@ -1,12 +1,8 @@
using Avalonia.Controls;
namespace Bitvault.Avalonia
namespace Bitvault.Avalonia;
public partial class LockView : UserControl
{
public partial class LockView : Window
{
public LockView()
{
InitializeComponent();
}
}
public LockView() => InitializeComponent();
}
+2
View File
@@ -16,5 +16,7 @@ public class VaultComponent :
services.AddTemplate<ArchiveNavigationViewModel, ArchiveNavigationView>();
services.AddTemplate<VaultViewModel, VaultView>("Vault");
services.AddTemplate<LockViewModel, LockView>("Lock");
});
}
+7 -1
View File
@@ -5,4 +5,10 @@
xmlns:vm="using:Bitvault"
x:DataType="vm:VaultNavigationViewModel"
Content="{Binding Name}"
MenuItemsSource="{Binding}" />
MenuItemsSource="{Binding}">
<Interaction.Behaviors>
<EventTriggerBehavior EventName="Loaded">
<NavigateAction Context="Main" Route="Lock" />
</EventTriggerBehavior>
</Interaction.Behaviors>
</NavigationViewItem>