Improvement to navigation regions
This commit is contained in:
@@ -12,10 +12,12 @@
|
||||
<CornerRadius x:Key="NavigationViewContentGridCornerRadius">0</CornerRadius>
|
||||
<Thickness x:Key="NavigationViewContentGridBorderThickness">1,0,0,0</Thickness>
|
||||
</NavigationView.Resources>
|
||||
<Frame x:Name="Main">
|
||||
<Frame>
|
||||
<Interaction.Behaviors>
|
||||
<EventTriggerBehavior EventName="Loaded">
|
||||
<NavigateAction Context="Main" Route="Vault" />
|
||||
<NavigateRegionAction Name="Main">
|
||||
<NavigateAction Context="Main" Route="Vault" />
|
||||
</NavigateRegionAction>
|
||||
</EventTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
</Frame>
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using Avalonia.Controls;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
[NavigationTarget("Main")]
|
||||
public partial class MainView : UserControl
|
||||
{
|
||||
public MainView() => InitializeComponent();
|
||||
|
||||
@@ -7,10 +7,12 @@
|
||||
x:DataType="vm:MainWindowViewModel"
|
||||
Background="Transparent"
|
||||
TransparencyLevelHint="Mica">
|
||||
<ContentControl x:Name="Window">
|
||||
<ContentControl>
|
||||
<Interaction.Behaviors>
|
||||
<AttachedBehaviour>
|
||||
<NavigateAction Context="Window" Route="Main" />
|
||||
<NavigateRegionAction Name="Window">
|
||||
<NavigateAction Context="Window" Route="Main" />
|
||||
</NavigateRegionAction>
|
||||
</AttachedBehaviour>
|
||||
</Interaction.Behaviors>
|
||||
</ContentControl>
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using FluentAvalonia.UI.Windowing;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
[NavigationTarget("Window")]
|
||||
public partial class MainWindow : AppWindow
|
||||
{
|
||||
public MainWindow()
|
||||
|
||||
@@ -5,11 +5,21 @@
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:Name="Name"
|
||||
x:CompileBindings="False"
|
||||
x:DataType="vm:VaultContentNavigationViewModel"
|
||||
Content="{Binding Name}">
|
||||
x:DataType="vm:VaultContentNavigationViewModel">
|
||||
<Interaction.Behaviors>
|
||||
<DataTriggerBehavior Binding="{Binding Selected}" Value="True">
|
||||
<NavigateAction Context="Content" Route="VaultContent" />
|
||||
<NavigateAction Context="{Binding Named, StringFormat='{}{0}:Content'}" Route="VaultContent" />
|
||||
</DataTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
<Grid ColumnDefinitions="Auto,*">
|
||||
<PersonPicture
|
||||
Grid.Column="0"
|
||||
Height="34"
|
||||
Margin="0"
|
||||
DisplayName="{Binding Name}" />
|
||||
<StackPanel Grid.Column="1" Margin="12,12,6,12">
|
||||
<TextBlock FontWeight="SemiBold" Text="{Binding Name}" />
|
||||
<TextBlock Opacity="0.7" Text="{Binding Name}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</ListBoxItem>
|
||||
|
||||
@@ -47,9 +47,21 @@
|
||||
Padding="4"
|
||||
BorderBrush="{DynamicResource DividerStrokeColorDefaultBrush}"
|
||||
BorderThickness="0,0,0,1">
|
||||
<ContentControl x:Name="ContentHeader" />
|
||||
<ContentControl x:Name="ContentHeader">
|
||||
<Interaction.Behaviors>
|
||||
<AttachedBehaviour>
|
||||
<NavigateRegionAction Name="{Binding Named, StringFormat='{}{0}:ContentHeader'}" />
|
||||
</AttachedBehaviour>
|
||||
</Interaction.Behaviors>
|
||||
</ContentControl>
|
||||
</Border>
|
||||
<Frame x:Name="Content" Grid.Row="1" />
|
||||
<Frame x:Name="Content" Grid.Row="1">
|
||||
<Interaction.Behaviors>
|
||||
<AttachedBehaviour>
|
||||
<NavigateRegionAction Name="{Binding Named, StringFormat='{}{0}:Content'}" />
|
||||
</AttachedBehaviour>
|
||||
</Interaction.Behaviors>
|
||||
</Frame>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
using Avalonia.Controls;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
[NavigationTarget("Content")]
|
||||
[NavigationTarget("ContentHeader")]
|
||||
public partial class VaultView : UserControl
|
||||
{
|
||||
public VaultView() => InitializeComponent();
|
||||
|
||||
@@ -10,18 +10,21 @@ public partial class VaultContentNavigationViewModel(IServiceProvider provider,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template,
|
||||
NamedComponent named,
|
||||
string name,
|
||||
string description) :
|
||||
ObservableViewModel(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
[ObservableProperty]
|
||||
private bool selected;
|
||||
private string? description = description;
|
||||
|
||||
[ObservableProperty]
|
||||
private string? name = name;
|
||||
|
||||
[ObservableProperty]
|
||||
private string? description = description;
|
||||
private string named = $"{named}";
|
||||
|
||||
[ObservableProperty]
|
||||
private bool selected;
|
||||
public IContentTemplate Template { get; set; } = template;
|
||||
}
|
||||
+14
-10
@@ -12,12 +12,16 @@ public partial class VaultViewModel(IServiceProvider provider,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template,
|
||||
NamedComponent named,
|
||||
string? filter = null) : ObservableCollectionViewModel<VaultContentNavigationViewModel>(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
INotificationHandler<Vault<Filter<string>>>
|
||||
{
|
||||
[ObservableProperty]
|
||||
private string? filter = filter;
|
||||
|
||||
[ObservableProperty]
|
||||
private string named = $"{named}";
|
||||
|
||||
public IContentTemplate Template { get; set; } = template;
|
||||
|
||||
public override async Task Activated()
|
||||
@@ -32,16 +36,16 @@ public partial class VaultViewModel(IServiceProvider provider,
|
||||
await base.Deactivated();
|
||||
}
|
||||
|
||||
protected override IEnumerate PrepareEnumeration(object? key) =>
|
||||
Enumerate<VaultContentNavigationViewModel>.With(new VaultViewModelOptions { Filter = Filter }) with { Key = key };
|
||||
|
||||
public async Task Handle(Vault<Filter<string>> args,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (args.Value is Filter<string> filter)
|
||||
public async Task Handle(Vault<Filter<string>> args,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
Filter = filter.Value;
|
||||
await Enumerate();
|
||||
if (args.Value is Filter<string> filter)
|
||||
{
|
||||
Filter = filter.Value;
|
||||
await Enumerate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override IEnumerate PrepareEnumeration(object? key) =>
|
||||
Enumerate<VaultContentNavigationViewModel>.With(new VaultViewModelOptions { Filter = Filter }) with { Key = key };
|
||||
}
|
||||
Reference in New Issue
Block a user