Open edongashi opened 6 years ago
Hey, I ran into this problem recentlty and I think it's a good idea: Add a attribute to override the type builder, for example I needed a DateTimePicker but with a mask, so I had to use a ConvertField but there was no way to override it, so I manually changed it.
Is it possible to use a mask with the calendar picker control? Do we need to modify the underlying textbox via template, or is there an easier way?
I believe we can't use masks on calendars (Not sure tho), what I meant was something like
[Override(typeof(ConvertedField))]
public DateTime Date { get; set; }
and it would force the builder to use the specified type
I looked at the code but this seems quite difficult, since lookup is done in a forward fashion from prop/type to builder. Forcing a specific type would require runtime checking (builders can be added or removed, this can cause unexpected states).
A simple solution would be adding a new builder for DateTime..
FormBuilder.Default.TypeBuilders[typeof(DateTime)].Insert(0, new CustomDateBuilder(...)))
where CustomDateBuilder
checks some condition. If that condition matches (for example [Masked]
) then return a converted field, else return null to pass.
Hey, just leaving it here to try to make it later:
Mapper<TClass>
to map from a class extension or at runtime (Or both). I think this is going to take some timeWhat is the mapper stuff about? I checked the code, something like proxying objects?
@EdonGashi Hey I was taking a look on the progress bar stuff and tough to myself: We could implement the progress button from MaterialDesignInXamlToolkit, this would be great for forms that need to do some async stuff like HTTP. Oh and I've changed this thread style and added [Password]
support 🎉
Thanks @redbaty for all the effort. The button would definitely be nice for async actions. There is also a stepper control which would be. :fire: if we could integrate that in a nice way.
An idea:
[Step("Personal details.")]
public string Name ...
public DateTime DoB...
[Step("Billing information")]
public string CardNumber ...
...
@EdonGashi Yeah the stepper would be really nice, I think I'll try to introduce the loading button and the progress bar tomorrow and in the next days I'll take a look on how we could do the stepper thingy. But anyway this is a really great library, I should be the one thanking you! 😄
This can be used alongside the [Field]
attribute to listen to the keyup event and act as a [Action]
attribute. @EdonGashi any idea how we would implement this? Is there a common presenter for fields?
For fields such as StringField
the hierarchy goes like this:
StringField : DataFormField : FormField : FormElement
DataFormField
should handle Read-Write props. Regarding the views generated I'm not sure how we can extract something in common, a place to consider would be IBindingProvider
, which gets bindings for fields.
I'm not quite sure I understand the meaning behind [Submit]
, something like dispatch an action when the field changes? Could something like [Field(OnChange=...)]
work? Otherwise we can always put classic setters in properties:
public string Something
{
get
{
return something;
}
set
{
something = value;
OnSomethingChanged();
}
}
@EdonGashi Sorry I thought I had written it, I mean to submit this form when someone press "enter", this should work similar to the [Action] attribute
[Action(IsDefault = true)]
should trigger on enter. Could you test this quickly?
@EdonGashi Yup just a sec
@EdonGashi Using the following does not work.
[Action("ok", "Entrar", IsLoading = "{Binding IsLoading}", IsDefault = true)]
Looks like this property exists in the attribute but it's not added in ActionElement
. It needs to have a
public IValueProvider IsDefault { get; set; }
public IValueProvider IsCancel { get; set; }
which should be initialized from the attribute and then added to resources on Freeze()
. After this the button in the template should do IsDefault={FormBinding IsDefault}
and IsCancel={FormBinding IsCancel}
@EdonGashi Hmmm, I've added it but it still won't work, am I missing something? Check it out on 40d810bf3fd4bb789b27b2acfab42fd26543db95
Fixed, ActionAttribute
didn't initialize the values. Also removed those fields from ActionElementCommand
because it doesn't need them.
During a Freeze()
the resources are linked to their names, which can then be accessed using {FormBinding ResourceName}
[ScriptAction("INCREMENT", "this.Counter++")]