Fixed selection
This commit is contained in:
@@ -22,7 +22,6 @@
|
||||
Margin="2,-1,0,0"
|
||||
ItemTemplate="{ReflectionBinding Template}"
|
||||
ItemsSource="{Binding}"
|
||||
SelectedIndex="{Binding SelectedIndex}"
|
||||
SelectionMode="AlwaysSelected">
|
||||
<ListBox.Styles>
|
||||
<Style Selector="ListBoxItem">
|
||||
|
||||
@@ -3,8 +3,29 @@
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:ItemNavigationViewModel">
|
||||
x:DataType="vm:ItemNavigationViewModel"
|
||||
IsSelected="{Binding Selected}">
|
||||
<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">
|
||||
<NavigateAction
|
||||
Context="{Binding Named, StringFormat='{}{0}:ContentHeader'}"
|
||||
|
||||
@@ -47,16 +47,19 @@ public class ContainerViewModelHandler(IDbContextFactory<ContainerDbContext> dbC
|
||||
|
||||
}, cancellationToken);
|
||||
|
||||
bool selected = true;
|
||||
foreach (var item in items)
|
||||
{
|
||||
IServiceScope serviceScope = serviceProvider.CreateScope();
|
||||
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 });
|
||||
await publisher.Publish(Create.As(viewModel), nameof(ContainerViewModel), cancellationToken);
|
||||
}
|
||||
|
||||
selected = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@ public partial class ItemNavigationViewModel(IServiceProvider provider,
|
||||
NamedComponent named,
|
||||
int id,
|
||||
string name,
|
||||
string description) :
|
||||
string description,
|
||||
bool selected) :
|
||||
ObservableViewModel(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
INotificationHandler<ArchiveEventArgs<Item>>,
|
||||
IRemovable
|
||||
@@ -31,7 +32,8 @@ public partial class ItemNavigationViewModel(IServiceProvider provider,
|
||||
private string named = $"{named}";
|
||||
|
||||
[ObservableProperty]
|
||||
private bool selected;
|
||||
private bool selected = selected;
|
||||
|
||||
public IContentTemplate Template { get; set; } = template;
|
||||
|
||||
public Task Handle(ArchiveEventArgs<Item> args,
|
||||
|
||||
Reference in New Issue
Block a user