I am building a wizard-like detail view popup for handling a multi-step workflow. I have created the necessary layout in Model.xafml, and am able to display and click between tabs. But I want to add Next/Previous buttons to the view, and programmatically switch between tabs. The issue I am having is that I need to interact with a child listview on the newly active tab. But the list view doesn't exist yet.
I've tried using a ManualResetEvent, to wait for the child view to get created. But then it blocks and the view doesn't get created. So I need to create some sort of callback or event that I can trigger when on the new tab, and the controls are created.
I'm at a bit of a loss how to set this up, and even how to describe what I need to do. How do I wait for the new tab to finish loading?
public void Next_Clicked() { var index = ++tabModel.ActiveTabIndex; if (index == 1) { var retries = 0; // NOTE: attempted to wait for PoliciesFrame to exist while (!PoliciesListViewCreated.WaitOne(1000) && retries++< 5) { } // NOTE: this line fails because PoliciesFrame is null var linkUnlinkController = PoliciesFrame.GetController<LinkUnlinkController>(); var window = Frame.GetController<WindowController>().Window; // display the link popup automatically. linkUnlinkController.LinkAction.DoExecute(window); } } protected override void CustomizeWindowPopup(object sender, CustomizePopupWindowParamsEventArgs e) { base.CustomizeWindowPopup(sender, e); DetailView.CustomizeViewItemControl<ListPropertyEditor>(this, ChildPropertyEditor, nameof(Transaction.Policies)); } private void ChildPropertyEditor(ListPropertyEditor listPropertyEditor) { PoliciesListView = listPropertyEditor.ListView; PoliciesFrame = listPropertyEditor.Frame; PoliciesListView.SelectionChanged += NestedListView_SelectionChanged; // NOTE: this is not working. How to notify when ready? PoliciesListViewCreated.Set(); }