Dropdown won't accept defaultValue change - semantic-ui

https://codesandbox.io/s/pQoyXymr2
Here's the demo. It seems Dropdown only receive defaultValue once, and not changing after, why?

defaultValue will affect only initial component value, so need to use the value prop to control Dropdown's value. This follows React's patterns with uncontrolled and controlled components.

Related

Is it ok to build ViewCell in OnBindingContextChanged event?

I have some custom ViewCell elements and most of them show and hide some components according to some properties of the BindingContext. I need to check values of some properties and show and hide some elements in the ViewCell, and also adjust the cell height accordingly.
Instead of writing value converters for most of the properties, I convert the BindingContext to underlying type and check the values of the properties in the OnBindingContextChanged event and right after that I build the UI with the relevant controls.
Do you think this is a bad way? Or is it ok?
I think it sounds quite counter-intuitive with regards to the MVVM model. Would you not be best binding the IsVisible property of the controls to a property determined in the ModelView?
e.g.
var label = new Label();
label.setBinding<ViewModel>(Label.IsVisibleProperty, vm => vm.IsLabelVisible, BindingMode.TwoWay);
You can then control the value of the IsLabelVisible property within the ViewModel instance.
One gotcha to consider is draw cycles and I would advise wrapping elements with toggled visibility states in Layout class.
Take a look at DataTemplateSelector pattern (similar to WPF):
http://forums.xamarin.com/discussion/comment/66502/#Comment_66502

Flex properties that "restrict" input but are not handled in Validators

I have what may seem like a somewhat odd question. I'm trying to think of all the properties that can be set on Components that restrict/validate input in a way that are not handled by Validators.
For example, the "restrict" property can be set on Components of type SkinnableTextBase. restrict is a property that restricts input but a Validator doesn't handle it.
Another example is the "minimum" property. The minimum property can be set on Components of type Range and again it kind of restricts input.
So I'm looking for any properties like these.
Right now I have:
maximum
minimum
restrict
maxChars
Thanks!

Flex - Show/Hide ComboBox based off selection

Is it possible to show or hide a comboBox based off the selection made in another comboBox. I have been looking for documentation on this to no avail.
Thanks
Yes, in a Change handler of ComboBox1 set ComboBox2's visible property to false based on the selected item.
Along with setting the combobox's visible property, if you want the form to act as if the combobox is not there, also set the includeInLayout property.

How do I make a skin aware of changes of value of a hostComponent's property?

I am writing a component and its skin. The skin has a "selected" state where it renders things with the corresponding glow.
It so happens that the being selected state is held at a property in the hostComponent, which is set/unset externally (not by a direct user interaction on the skin).
I tried making this boolean property of the hostComponent a SkinPart, and at skin initialization set up a ChangeWatcher on this property that would trigger the state change. No cigar. :(
What's the way to make the skin's state change through the hostComponent?
What's the way to make the skin's state change through the hostComponent?
Call invalidateSkinState() in your hostComponent's property.
That will in turn force commitProperties to rerun during the next render event which will in turn force getCurrentSkinState() to re-run when commitProperties runs.
Make sure that your hostComponent implements getCurrentSkinState() and returns the string value representing the state you want to go to.

obout combobox setValue()

I am using an obout combobox to display color swatches for a product catalog and it's very cool except for one thing.
When on the server, I set the .Value property explicity (for a reset) it IS setting on the serverside, but not in the client.
For example, I add all my color swatches from Linq, but then add a default setting of "Color..." with a value of "". But on first display the combobox shows as empty (the text part). When I click the down arrow, then everything is correct.
I've tried setting the index, the value, the text and none work.
I have also added a registerclientscript to try and force this on the client side and while the script is running (test with an alert), the box is not getting set.
Any ideas?
Apparently you cannot set a value to "", you must set it to " ". Then it will work. :)

Resources