Fixed selection
This commit is contained in:
@@ -22,7 +22,6 @@
|
|||||||
Margin="2,-1,0,0"
|
Margin="2,-1,0,0"
|
||||||
ItemTemplate="{ReflectionBinding Template}"
|
ItemTemplate="{ReflectionBinding Template}"
|
||||||
ItemsSource="{Binding}"
|
ItemsSource="{Binding}"
|
||||||
SelectedIndex="{Binding SelectedIndex}"
|
|
||||||
SelectionMode="AlwaysSelected">
|
SelectionMode="AlwaysSelected">
|
||||||
<ListBox.Styles>
|
<ListBox.Styles>
|
||||||
<Style Selector="ListBoxItem">
|
<Style Selector="ListBoxItem">
|
||||||
|
|||||||
@@ -3,8 +3,29 @@
|
|||||||
xmlns="https://github.com/avaloniaui"
|
xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:vm="using:Bitvault"
|
xmlns:vm="using:Bitvault"
|
||||||
x:DataType="vm:ItemNavigationViewModel">
|
x:DataType="vm:ItemNavigationViewModel"
|
||||||
|
IsSelected="{Binding Selected}">
|
||||||
<Interaction.Behaviors>
|
<Interaction.Behaviors>
|
||||||
|
<EventTriggerBehavior EventName="Loaded">
|
||||||
|
<ConditionAction>
|
||||||
|
<ConditionAction.Condition>
|
||||||
|
<ConditionalExpression ForwardChaining="And">
|
||||||
|
<ComparisonCondition LeftOperand="{Binding Selected}" RightOperand="True" />
|
||||||
|
</ConditionalExpression>
|
||||||
|
</ConditionAction.Condition>
|
||||||
|
<NavigateAction
|
||||||
|
Context="{Binding Named, StringFormat='{}{0}:ContentHeader'}"
|
||||||
|
Route="ItemCommandHeader"
|
||||||
|
Scope="self" />
|
||||||
|
<NavigateAction Context="{Binding Named, StringFormat='{}{0}:Content'}" Route="Item">
|
||||||
|
<NavigateAction.ParameterBindings>
|
||||||
|
<ParameterBinding Key="Immutable" Value="{x:True}" />
|
||||||
|
<ParameterBinding Key="Id" Value="{Binding Id}" />
|
||||||
|
<ParameterBinding Key="Name" Value="{Binding Name}" />
|
||||||
|
</NavigateAction.ParameterBindings>
|
||||||
|
</NavigateAction>
|
||||||
|
</ConditionAction>
|
||||||
|
</EventTriggerBehavior>
|
||||||
<DataTriggerBehavior Binding="{Binding Selected}" Value="True">
|
<DataTriggerBehavior Binding="{Binding Selected}" Value="True">
|
||||||
<NavigateAction
|
<NavigateAction
|
||||||
Context="{Binding Named, StringFormat='{}{0}:ContentHeader'}"
|
Context="{Binding Named, StringFormat='{}{0}:ContentHeader'}"
|
||||||
|
|||||||
@@ -47,16 +47,19 @@ public class ContainerViewModelHandler(IDbContextFactory<ContainerDbContext> dbC
|
|||||||
|
|
||||||
}, cancellationToken);
|
}, cancellationToken);
|
||||||
|
|
||||||
|
bool selected = true;
|
||||||
foreach (var item in items)
|
foreach (var item in items)
|
||||||
{
|
{
|
||||||
IServiceScope serviceScope = serviceProvider.CreateScope();
|
IServiceScope serviceScope = serviceProvider.CreateScope();
|
||||||
IServiceFactory serviceFactory = serviceScope.ServiceProvider.GetRequiredService<IServiceFactory>();
|
IServiceFactory serviceFactory = serviceScope.ServiceProvider.GetRequiredService<IServiceFactory>();
|
||||||
|
|
||||||
if (serviceFactory.Create<ItemNavigationViewModel>(item.Id, item.Name, "Description " + 1) is ItemNavigationViewModel viewModel)
|
if (serviceFactory.Create<ItemNavigationViewModel>(item.Id, item.Name, "Description " + 1, selected) is ItemNavigationViewModel viewModel)
|
||||||
{
|
{
|
||||||
cache.Add(new Item { Id = item.Id, Name = item.Name });
|
cache.Add(new Item { Id = item.Id, Name = item.Name });
|
||||||
await publisher.Publish(Create.As(viewModel), nameof(ContainerViewModel), cancellationToken);
|
await publisher.Publish(Create.As(viewModel), nameof(ContainerViewModel), cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
selected = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ public partial class ItemNavigationViewModel(IServiceProvider provider,
|
|||||||
NamedComponent named,
|
NamedComponent named,
|
||||||
int id,
|
int id,
|
||||||
string name,
|
string name,
|
||||||
string description) :
|
string description,
|
||||||
|
bool selected) :
|
||||||
ObservableViewModel(provider, factory, mediator, publisher, subscriber, disposer),
|
ObservableViewModel(provider, factory, mediator, publisher, subscriber, disposer),
|
||||||
INotificationHandler<ArchiveEventArgs<Item>>,
|
INotificationHandler<ArchiveEventArgs<Item>>,
|
||||||
IRemovable
|
IRemovable
|
||||||
@@ -31,7 +32,8 @@ public partial class ItemNavigationViewModel(IServiceProvider provider,
|
|||||||
private string named = $"{named}";
|
private string named = $"{named}";
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool selected;
|
private bool selected = selected;
|
||||||
|
|
||||||
public IContentTemplate Template { get; set; } = template;
|
public IContentTemplate Template { get; set; } = template;
|
||||||
|
|
||||||
public Task Handle(ArchiveEventArgs<Item> args,
|
public Task Handle(ArchiveEventArgs<Item> args,
|
||||||
|
|||||||
Reference in New Issue
Block a user