Xamarin Forms updating Label Underline doesn't works - ios

I have a need where I need to dynamically keep changing the underline status of a particular Text in Xamarin Forms label.
After referring multiple posts on how to underline a label, I tried both the options, creating a custom renderer as well as using Effects. The text underlines fine. However the problem is that the underline status of the Label doesn't update. This problem however is only in iOS, Android works fine.
I created a bindable property HasUnderline in my Custom Label class in Xamarin Forms. The OnElementPropertyChange method in iOS is fired within the CustomRenderer. I then also change the underline property of the control using
text.AddAttribute(UIStringAttributeKey.UnderlineStyle, NSNumber.FromInt32((int)NSUnderlineStyle.Single), range);
However, the same is not reflected in the UI.
After so many hours of my head banging, I finally, however, did notice that if I change the value of the Text, the underline immediately reflects. So it appears the changing the underline property doesn't reflect until something in the content of the text is changed. But I don't want to change the text while adding/removing the underline.
How can I solve this issue?

Related

Codename One - addSubmitButtons method of Validator class changes button style

I'm developing a Codename One app for iOS.
I defined a button as follows:
Button signUpButton = new Button();
signUpButton.getAllStyles().setBorder(Border.createEmpty());
signUpButton.getAllStyles().setBgTransparency(255);
signUpButton.getAllStyles().setBgColor(0x9d1710);
signUpButton.getAllStyles().setFgColor(0x848484);
signUpButton.getAllStyles().setMargin(Component.LEFT, 4);
signUpButton.getAllStyles().setMargin(Component.RIGHT, 4);
signUpButton.setCapsText(true);
signUpButton.setText("Conferma");
After that, I created a Validator, I added some constraits to other text fields and then I added the button to the validator:
validator.addSubmitButtons(signUpButton);
The addSubmitButtons method changes the style I set for the button (in particular, the margins and size changed).
I also tried to set the style I want to the button after the addSubmitButtons method, but it seems it doesn't consider it. It happens on simulator and on device too.
This is what happens without calling the addSubmitButtons method:
This is what happens calling the addSubmitButtons method:
How can I solve that problem?
When the validation doesn't pass the button is set to disabled so the the disabled style is picked of the 4 styles.
I'm guessing here but I'm assuming that the margin/padding of the disabled style is still set in pixels instead of millimeters for the native theme. If you explicitly set all styles to use millimeters it should work.

Is it possible to change the color of a MaterialDesignIcon?

I use a MaterialDesignIcon in a label like this:
Label info = new Label("Label", MaterialDesignIcon.AC_UNIT.graphic("-fx-fill: red;"));
I don't know what CSS is supports (https://docs.oracle.com/javase/8/javafx/api/javafx/scene/doc-files/cssref.html) but I thought it was Text. -fx-underline worked and so did -fx-font-size. I understand that other font properties don't always work because the font doesn't support them, so that's fine. None of the Shape properties worked so the above fill doesn't do anything.
I only see the colors change by the Swatch but I want something local. What CSS properties are supported and how can I change a single icon's color?
MaterialDesignIcon.graphic() creates an instance of Label. So to change its color you can use fx-text-fill: red.
To inspect your GUI you can use ScenicView

data-placeholder and jQueryUI autocomplete

Is there a simple way to have a default text in the textbox using jQueryUI's autocomplete ?
I have tried using data-placeholder but it doesn't seem to work.
I have searched online, and people suggest using the textbox value to display the text, and clear it on focus. But then I would need to change the font style just for the default text, and check onKeyUp when the text is manually erased etc...
Is there no easier way to do this ? or am I missing something ?
A lot of people will use a span that is positioned to be over the text box. When the text box gets focus then you hide the span. When the text box blurs and has a value, you don't show it. If it doesn't have a value then you can show it again.
You can style the span however you want independently of the text box so you would not have to change the font style on the text box itself. You would have to subscribe to the focus and blur events, but it would be much easier if you created a jQuery plugin to do this. In fact, I'm sure there are ones that already exist that do this.

Silverlight UI Automation of a TextBlock

I'm trying to set up UI automation for Silverlight 3. I have a little test project that has 2 elements, a Button and a TextBlock. When you click the button the text is supposed to change.
I have been able to simulate a button click and the text does correctly change on the UI. However I am having problems retrieving the text from the TextBlock. UISpy shows that it is of type "text" but it also shows that it implements no control patterns. If I use a TextBox I can get the text correctly using a ValuePattern, but I would prefer to use TextBlock.
Does anyone know how to get the current text of a TextBlock from it's AutomationElement object?
TextBlock exposes its text as the Name property of the automation element, so you can read the text from myTextBlockAutomationElement.Current.Name.

How to change the color of some text in textbox - Silverlight 3?

I have a usual TextBox. I know in order to change the color of some text I can use Run tag. But when I try to use it imperatively instead declaratively (because I need to do that dynamically) I have the text in TextBox like
AAA<Run...>Text to be changed in color</Run>
and sure nothing in color changes.
How can I change the color of some text in some program way?
Thanks
I'm fairly sure you have to use a RichTextBox for that, TextBox only works with plaintext.

Resources