如何在FormFlow中更改默认按钮标签“No Preference”

问题描述 投票:1回答:1

有没有办法在更新用户输入时修改按钮的默认“无首选项”标签,例如“我不想改变任何事情。”没有引入新的资源。* .resx文件? No Preference button with the default label

我尝试了所有允许更改此类文字的模板,但我发现没有人能够实现这一目标。 TemplateUsage.NoPreference可用于仅更改可选字段的值,而不是按钮标签。

c# botframework formflow
1个回答
1
投票

您可以通过覆盖FormFlow中的Template值来实现。

以下是基于Microsoft.Bot.Sample.SimpleSandwichBot的示例:

public static IForm<SandwichOrder> BuildForm()
{
    var formBuilder = new FormBuilder<SandwichOrder>()
            .Message("Welcome to the simple sandwich order bot!");

    var noPreferenceStrings = new string[] { "Nothing" };

    // Set the new "no Preference" value
    formBuilder.Configuration.Templates.Single(t => t.Usage == TemplateUsage.NoPreference).Patterns = noPreferenceStrings;

    // Change this one to help detection of what you typed/selected
    formBuilder.Configuration.NoPreference = noPreferenceStrings;

    return formBuilder.Build();
}

演示捕获:

demo

© www.soinside.com 2019 - 2024. All rights reserved.