@@ -18,52 +18,17 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
1818 Automation::AutomationProperties::SetName (AddNewButton (), RS_ (L" Actions_AddNewTextBlock/Text" ));
1919 }
2020
21- Automation::Peers::AutomationPeer Actions::OnCreateAutomationPeer ()
22- {
23- _ViewModel.OnAutomationPeerAttached ();
24- return nullptr ;
25- }
26-
2721 void Actions::OnNavigatedTo (const NavigationEventArgs& e)
2822 {
2923 _ViewModel = e.Parameter ().as <Editor::ActionsViewModel>();
30-
31- // Subscribe to the view model's FocusContainer event.
32- // Use the KeyBindingViewModel or index provided in the event to focus the corresponding container
33- _ViewModel.FocusContainer ([this ](const auto & /* sender*/ , const auto & args) {
34- if (auto kbdVM{ args.try_as <KeyBindingViewModel>() })
35- {
36- if (const auto & container = KeyBindingsListView ().ContainerFromItem (*kbdVM))
37- {
38- container.as <Controls::ListViewItem>().Focus (FocusState::Programmatic);
39- }
40- }
41- else if (const auto & index = args.try_as <uint32_t >())
42- {
43- if (const auto & container = KeyBindingsListView ().ContainerFromIndex (*index))
44- {
45- container.as <Controls::ListViewItem>().Focus (FocusState::Programmatic);
46- }
47- }
48- });
49-
50- // Subscribe to the view model's UpdateBackground event.
51- // The view model does not have access to the page resources, so it asks us
52- // to update the key binding's container background
53- _ViewModel.UpdateBackground ([this ](const auto & /* sender*/ , const auto & args) {
54- if (auto kbdVM{ args.try_as <KeyBindingViewModel>() })
55- {
56- if (kbdVM->IsInEditMode ())
57- {
58- const auto & containerBackground{ Resources ().Lookup (box_value (L" ActionContainerBackgroundEditing" )).as <Windows::UI::Xaml::Media::Brush>() };
59- kbdVM->ContainerBackground (containerBackground);
60- }
61- else
62- {
63- const auto & containerBackground{ Resources ().Lookup (box_value (L" ActionContainerBackground" )).as <Windows::UI::Xaml::Media::Brush>() };
64- kbdVM->ContainerBackground (containerBackground);
65- }
66- }
24+ _ViewModel.CurrentPage (ActionsSubPage::Base);
25+ auto vmImpl = get_self<ActionsViewModel>(_ViewModel);
26+ vmImpl->MarkAsVisited ();
27+ _layoutUpdatedRevoker = LayoutUpdated (winrt::auto_revoke, [this ](auto /* s*/ , auto /* e*/ ) {
28+ // Only let this succeed once.
29+ _layoutUpdatedRevoker.revoke ();
30+
31+ AddNewButton ().Focus (FocusState::Programmatic);
6732 });
6833
6934 TraceLoggingWrite (
@@ -74,9 +39,4 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
7439 TraceLoggingKeyword (MICROSOFT_KEYWORD_MEASURES),
7540 TelemetryPrivacyDataTag (PDT_ProductAndServiceUsage));
7641 }
77-
78- void Actions::AddNew_Click (const IInspectable& /* sender*/ , const RoutedEventArgs& /* eventArgs*/ )
79- {
80- _ViewModel.AddNewKeybinding ();
81- }
8242}
0 commit comments