如何将Prompt.Choice()的结果转发到当前对话框? [英] How to forward result of Prompt.Choice() to current dialog?

查看:68
本文介绍了如何将Prompt.Choice()的结果转发到当前对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PromptDialog.Choice()向用户展示不同的选项.尝试次数设置为0,因此,如果键入无效选项,则不会重试.

在这种情况下,我想将输入的文本传递给出现的当前对话框,以提示并让其处理消息.

这样做的正确方法是什么?我尝试在提示对话框的恢复处理程序中创建一个新活动,并直接调用MessageReceivedAsync()方法,但是a)不能按预期工作,b)似乎是黑客.

一个例子是提示您询问我不确定您想做什么.显示帮助还是继续尝试?"的提示.有两个选项帮助"和继续尝试".但是,如果用户现在输入一加一是什么?",我希望当前对话框可以处理此问题.

我还可以提出不同的问题:如何用另一个对话框替换堆栈顶部的当前对话框?这样我就可以调用相同的对话框.

解决方案

我认为调用MessageReceivedAsync是到达这里的方法.关键是要从正在创建的活动中传递IAwaitable.

代码应类似于:

await MessageReceivedAsync(context, Awaitable.FromItem(yourActivity));

I'm using PromptDialog.Choice() to present different options to my users. The number of attempts is set to 0, so if they type in anything that is not a valid option, there won't be any retries.

In this case I would like to pass the entered text to the current dialog who has presented to prompt and let it handle the message.

What is the correct way of doing this? I tried creating a new activity in the resume-handler of the prompt dialog and directly call the MessageReceivedAsync() method but that a) does not work as expected and b) seems to be a hack.

An example would be a prompt that asks "I'm not sure what you want to do. Show help or keep trying?" with two options "Help" and "Keep trying". However, if the user now enters "what is one plus one?", I'd like the current dialog to handle this.

I could also ask differently: how can I replace the current dialog on top of the stack with another one? This would allow me to just call the same dialog.

解决方案

I think that calling MessageReceivedAsync will be the way to go here. The key is to pass an IAwaitable from the activity you are creating.

The code should be like:

await MessageReceivedAsync(context, Awaitable.FromItem(yourActivity));

这篇关于如何将Prompt.Choice()的结果转发到当前对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆