WPF-Forge/Forge.Forms

Select/combobox

skadefro opened this issue · 2 comments

Hey
I'm trying to create a combobox/select from a list, not a hardcoded list of options.
Is that possible ?
I have look at FormBuilder and looks it should support setting the list using the "from" property.
I tried with array of string, array of Forge.Forms.FormBuilding.SelectOption and JArray containing object's with a Name and Value.

Select in xmlString

    <select from="{ContextBinding Doctors}" name="Doctor" label="Appointed doctor"
displayPath="Name" valuePath="Value"
 />

Show form

                var f = new Form(xmlString);
                f.defaults = param;
                f.Topmost = true;
                if (f.ShowDialog() == false)
                {
                    if (f.LastError != null) LastError = f.LastError;
                }

So "params" is an Dictionary<string, object>(); and in that i have added add Doctor as a string, and I have tried adding Doctors as several different types including the mentioned above but with no luck so far.
Is this even possible ?

Hi @skadefro.

The From property can be bound to a collection of items. The XML you posted should work, under the assumption that there's a non-null Doctors property in your Form.Context.

If you want to access things from the model itself, use {Binding}, example {Binding Doctors} or {Binding defaults.Doctors}.

Ahh, Binding Doctors worked :-) thank you very much for a fast, informative and precise response.