edongashi / WpfMaterialForms

Dynamically generated forms and dialogs in WPF
MIT License
51 stars 14 forks source link

NumberRange in dynamic forms #19

Open hashitha opened 6 years ago

hashitha commented 6 years ago

is NumberRange available for DynamicForms?

redbaty commented 6 years ago

I don't think so, as WPF does not officially support it, though we could implement it. You can bind it to a integer and specify its range too.

hashitha commented 6 years ago

Sorry, I meant to have a slider like in the old demo volume slider which uses NumberRangeSchema

image

redbaty commented 6 years ago

@hashitha Oh alright, yes I think we missed it (Although we need @EdonGashi to confirm it). Either way, this doesn't seem difficult to implement, I'll try to add it to my fork later.

edongashi commented 6 years ago

A [Slider] attribute should be a good fit for this control. Basically we add a PropertyBuilder that checks for this attribute and returns the respective control.

For xml we can do something like

<!-- Instead of input we do slider-->
<input type="int" ... />
<slider type="int" ... />

<!-- We also need support for a select tag -->
<select type="string" from="{Binding Items}" />
<select type="string">
  <option value="Option 1" />
  <option value="Option 2" />
  <option value="Option 3" />
</select>

Besides xml support new controls must also support metro and wpf. So we must consider 4 implementations for each new field type. Takes a little more time but nothing undoable.

edongashi commented 6 years ago

Added [Slider(Minimum = ..., Maximum = ..., IsDiscrete = ....)] IsDiscrete is not yet implemented.

Check Settings model for demo