2016-05-30 104 views
3

我有一個簡單的形式調用形式,從對話框

[Serializable] 
class CreateNewLeadForm 
{ 
    public string FirstName; 
    public string LastName; 
    public static IForm<CreateNewLeadForm> BuildForm() 
    { 

     return new FormBuilder<CreateNewLeadForm>() 
      .Message("Lets create a New Lead") 
      .Field(nameof(FirstName)) 
      .Field(nameof(LastName)) 
      .Build(); 

    } 
}; 

和一個簡單的對話框,

public class GreetDialog : IDialog<object> 
{   
    public async Task StartAsync(IDialogContext context) 
    { 

     context.Wait(MessageReceivedAsync); 
    } 
    public async Task MessageReceivedAsync(IDialogContext context, IAwaitable<Message> argument) 
    { 
     context.Wait(MessageReceivedAsync); 
    } 
} 

我如何調用,在主對話框本身啓動一個FormDialog?總的來說,我們如何在Dialog中引入新的對話框?

回答

6

爲了啓動FormDialog你可以這樣做:

var myform = new FormDialog<CreateNewLeadForm>(new CreateNewLeadForm(), CreateNewLeadForm.BuildForm, FormOptions.PromptInStart, null); 

context.Call<CreateNewLeadForm>(myform, FormCompleteCallback); 

看看到PizzaBot爲例。

要啓動對話框中的新的對話框,你可以這樣做:

  • context.Call傳遞新的對話框的實例和完成回調(如表格)
  • context.Forward在那裏你可以轉發消息到子對話框

    context.Forward(new MyChildDialog(),ResumeAfterChildDialog,message,CancellationToken.None);