Ensure a locker is selected in first load
This commit is contained in:
@@ -36,7 +36,7 @@
|
||||
Region="{Binding Named, StringFormat='{}{0}:Content'}"
|
||||
Route="Item"
|
||||
Scope="self">
|
||||
<Parameter Key="test" Value="{x:True}" />
|
||||
<Parameter Key="FromCategory" Value="{x:True}" />
|
||||
<Parameter Key="State" Value="{x:Static vm:ItemState.Write}" />
|
||||
</NavigateAction>
|
||||
</EventTriggerBehavior>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
Region="{Binding Named, StringFormat='{}{0}:Content'}"
|
||||
Route="Item"
|
||||
Scope="self">
|
||||
<Parameter Key="test" Value="{x:True}" />
|
||||
<Parameter Key="FromCategory" Value="{x:True}" />
|
||||
<Parameter Key="State" Value="{x:Static vm:ItemState.Write}" />
|
||||
</NavigateAction>
|
||||
</EventTriggerBehavior>
|
||||
|
||||
@@ -19,10 +19,11 @@
|
||||
Region="{Binding Named, StringFormat='{}{0}:Content'}"
|
||||
Route="Item"
|
||||
Scope="self">
|
||||
<Parameter Key="FromCategory" Value="{x:False}" />
|
||||
<Parameter Key="State" Value="{x:Static vm:ItemState.Read}" />
|
||||
<Parameter Key="Name" Value="{Binding Name}" />
|
||||
<Parameter Key="Archived" Value="{Binding Archived}" />
|
||||
<Parameter Key="Favourite" Value="{Binding Favourite}" />
|
||||
<Parameter Key="Archived" Value="{Binding Archived}" />
|
||||
</NavigateAction>
|
||||
</ConditionAction>
|
||||
</AttachedBehaviour>
|
||||
@@ -31,10 +32,11 @@
|
||||
Region="{Binding Named, StringFormat='{}{0}:Content'}"
|
||||
Route="Item"
|
||||
Scope="self">
|
||||
<Parameter Key="FromCategory" Value="{x:False}" />
|
||||
<Parameter Key="Name" Value="{Binding Name}" />
|
||||
<Parameter Key="Immutable" Value="{x:Static vm:ItemState.Read}" />
|
||||
<Parameter Key="Archived" Value="{Binding Archived}" />
|
||||
<Parameter Key="State" Value="{x:Static vm:ItemState.Read}" />
|
||||
<Parameter Key="Favourite" Value="{Binding Favourite}" />
|
||||
<Parameter Key="Archived" Value="{Binding Archived}" />
|
||||
</NavigateAction>
|
||||
</DataTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<ConditionAction>
|
||||
<ConditionAction.Condition>
|
||||
<ConditionalExpression ForwardChaining="And">
|
||||
<ComparisonCondition LeftOperand="{Binding Test}" RightOperand="True" />
|
||||
<ComparisonCondition LeftOperand="{Binding FromCategory}" RightOperand="True" />
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<NavigateBackAction Region="Left" />
|
||||
@@ -32,7 +32,7 @@
|
||||
Region="{Binding Named, StringFormat='{}{0}:Content'}"
|
||||
Route="Item"
|
||||
Scope="self">
|
||||
<Parameter Key="test" Value="{x:True}" />
|
||||
<Parameter Key="FromCategory" Value="{x:True}" />
|
||||
<Parameter Key="State" Value="{x:Static vm:ItemState.Write}" />
|
||||
</NavigateAction>
|
||||
</DataTriggerBehavior>
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
x:DataType="vm:LockerNavigationViewModel"
|
||||
Content="{Binding Name}"
|
||||
IsExpanded="{Binding Expanded}"
|
||||
IsSelected="{Binding Selected}"
|
||||
MenuItemsSource="{Binding}"
|
||||
NavigationViewItemExtension.IsItemClickEnabled="True"
|
||||
SelectsOnInvoked="True">
|
||||
@@ -16,7 +15,7 @@
|
||||
<ConditionAction>
|
||||
<ConditionAction.Condition>
|
||||
<ConditionalExpression ForwardChaining="And">
|
||||
<ComparisonCondition LeftOperand="{Binding Selected}" RightOperand="True" />
|
||||
<ComparisonCondition LeftOperand="{Binding $parent[NavigationViewItem].IsSelected}" RightOperand="True" />
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<NavigateAction Region="Main" Route="OpenLocker">
|
||||
@@ -32,7 +31,7 @@
|
||||
<ConditionAction>
|
||||
<ConditionAction.Condition>
|
||||
<ConditionalExpression ForwardChaining="And">
|
||||
<ComparisonCondition LeftOperand="{Binding Selected}" RightOperand="True" />
|
||||
<ComparisonCondition LeftOperand="{Binding $parent[NavigationViewItem].IsSelected}" RightOperand="True" />
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<ChangePropertyAction
|
||||
@@ -42,6 +41,28 @@
|
||||
<InvokeNavigationViewItemAction />
|
||||
</ConditionAction>
|
||||
</DataTriggerBehavior>
|
||||
<AttachedBehaviour>
|
||||
<ConditionAction>
|
||||
<ConditionAction.Condition>
|
||||
<ConditionalExpression ForwardChaining="And">
|
||||
<ComparisonCondition LeftOperand="{Binding Opened}" RightOperand="False" />
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<NavigateAction Region="Main" Route="OpenLocker">
|
||||
<Parameter Key="Name" Value="{Binding Name}" />
|
||||
</NavigateAction>
|
||||
</ConditionAction>
|
||||
<ConditionAction>
|
||||
<ConditionAction.Condition>
|
||||
<ConditionalExpression ForwardChaining="And">
|
||||
<ComparisonCondition LeftOperand="{Binding Opened}" RightOperand="True" />
|
||||
<ComparisonCondition LeftOperand="{Binding Activated}" RightOperand="False" />
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<NavigateAction Region="Main" Route="Locker" />
|
||||
<InvokeNavigationViewItemAction />
|
||||
</ConditionAction>
|
||||
</AttachedBehaviour>
|
||||
<AttachedEventTriggerBehaviour RoutedEvent="{x:Static NavigationViewItemExtension.ItemClickEvent}">
|
||||
<ConditionAction>
|
||||
<ConditionAction.Condition>
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
<NavigationView
|
||||
FooterMenuItemsSource="{Binding Footer}"
|
||||
MenuItemTemplate="{Binding Template}"
|
||||
MenuItemsSource="{Binding}">
|
||||
MenuItemsSource="{Binding}"
|
||||
SelectedItem="{Binding SelectedItem}"
|
||||
SelectionFollowsFocus="True">
|
||||
<NavigationView.Resources>
|
||||
<CornerRadius x:Key="NavigationViewContentGridCornerRadius">0</CornerRadius>
|
||||
<Thickness x:Key="NavigationViewContentGridBorderThickness">1,0,0,0</Thickness>
|
||||
|
||||
@@ -9,6 +9,7 @@ public class AggerateMainViewModelHandler(IPublisher publisher,
|
||||
{
|
||||
public Task Handle(AggerateEventArgs<IMainNavigationViewModel> args)
|
||||
{
|
||||
bool selected = true;
|
||||
foreach (IComponentHost locker in lockers.OrderBy(x => x.Services.GetRequiredService<IConfigurationDescriptor<LockerConfiguration>>()
|
||||
is IConfigurationDescriptor<LockerConfiguration> descriptor ? descriptor.Name : null))
|
||||
{
|
||||
@@ -16,10 +17,12 @@ public class AggerateMainViewModelHandler(IPublisher publisher,
|
||||
{
|
||||
if (locker.Services.GetRequiredService<IServiceFactory>() is IServiceFactory factory)
|
||||
{
|
||||
if (factory.Create<LockerNavigationViewModel>(descriptor.Name) is LockerNavigationViewModel viewModel)
|
||||
if (factory.Create<LockerNavigationViewModel>(descriptor.Name, selected) is LockerNavigationViewModel viewModel)
|
||||
{
|
||||
publisher.Publish(Create.As<IMainNavigationViewModel>(viewModel),
|
||||
nameof(MainViewModel));
|
||||
|
||||
selected = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,8 @@ public partial class ItemViewModel :
|
||||
private string name;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool test;
|
||||
private bool fromCategory;
|
||||
|
||||
public ItemViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
@@ -36,12 +37,12 @@ public partial class ItemViewModel :
|
||||
IContentTemplate template,
|
||||
NamedComponent named,
|
||||
ItemState state = ItemState.Read,
|
||||
bool test = false,
|
||||
bool fromCategory = false,
|
||||
string name = "",
|
||||
bool favourite = false,
|
||||
bool archived = false) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
Test = test;
|
||||
FromCategory = fromCategory;
|
||||
Named = $"{named}";
|
||||
Template = template;
|
||||
State = state;
|
||||
|
||||
@@ -9,7 +9,8 @@ public partial class LockerNavigationViewModel :
|
||||
INotificationHandler<OpenedEventArgs<Locker>>,
|
||||
INotificationHandler<ClosedEventArgs<Locker>>,
|
||||
INotificationHandler<ActivatedEventArgs<Locker>>,
|
||||
INotificationHandler<DeactivatedEventArgs<Locker>>
|
||||
INotificationHandler<DeactivatedEventArgs<Locker>>,
|
||||
ISelectable
|
||||
{
|
||||
[ObservableProperty]
|
||||
private bool activated;
|
||||
@@ -33,10 +34,12 @@ public partial class LockerNavigationViewModel :
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template,
|
||||
string name) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
string name,
|
||||
bool selected) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
Template = template;
|
||||
Name = name;
|
||||
Selected = selected;
|
||||
}
|
||||
|
||||
public IContentTemplate Template { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user