How to change the default button label “No Preference” in FormFlow

落爺英雄遲暮 提交于 2019-12-24 09:21:11

问题


Is there a way to modify the default "No Preference" label of the button when updating the user inputs to read e.g. "I don't want to change anything." without introducing a new Resources.*.resx file?

I tried all templates that allow changing such literals but I found no one that could achieve this. TemplateUsage.NoPreference can be used to change only the value of an optional field, not the button label.


回答1:


You can do it by overriding the Template value in your FormFlow.

Here is an example based on the 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 capture:



来源:https://stackoverflow.com/questions/48060923/how-to-change-the-default-button-label-no-preference-in-formflow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!