Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
When changing the background color on a entry nothing will happen until the entry will gain focus -> if it is already focused it must be unfocused and focused again.
The bug is in the FormsTextBox class, when changing the background only a property is set (BackgroundFocusBrush).
Once "OnGotFocus" is called the property value (BackgroundFocusBrush) is applied to the "BorderElement".
The reason for this was a problem when setting the background color on a focused entry:
//If we're on the phone, the Visual State Manager crashes if we try to
// handle alternate background colors in the focus state; we have to do
// it manually here"
So I figured maybe this would work now so i created my own renderer and used reflection to update the value on every "UpdateBackgroundColor" call.
protected override void UpdateBackgroundColor()
if (Control == null)
var info = typeof(FormsTextBox).GetField("_borderElement", BindingFlags.NonPublic | BindingFlags.Instance);
var _borderElement = info.GetValue(Control) as Border;
if (_borderElement != null)
_borderElement.Background = Control.BackgroundFocusBrush;
This works perfectly fine for me on Lumia 640 XL -> and updates even during editing the contents.
Are ther still cases when this would cause a crash? If not the border element should be updated normally instead of using another property to update it with "OnGotFocus".
If the problem persists, it should update on some other cases as well, right now I'm using the Entry coloring as validator -> i.e. when an input is mandatory the entry is yellow when it's empty... so with my change it will lose/gain the color while editing. Without the hack this won't work at all.
Created attachment 16990 [details]
Added a repro project to demonstrate the issue. Everything works as expected on the desktop (minus the problems described in https://bugzilla.xamarin.com/show_bug.cgi?id=43282), but the phone gets into a broken state once the Entry gains focus.
In the repro project, the toggle button works fine (changes the background between green and default) until the Entry gains focus; after that, the toggle stops working. Also, in the repro project the background of the Entry should turn red as soon as the user types a "4" anywhere in the box; this does not work on the phone.
I can see that it was fixed in version 2.3.2-pre2 for Entry but it still does not work for Editor (that is almost he same as entry)
(In reply to Karol S from comment #3)
> I can see that it was fixed in version 2.3.2-pre2 for Entry but it still
> does not work for Editor (that is almost he same as entry)
I've created bug 44584 for the Editor version of this issue.
Should be fixed in 2.3.3-pre3
Sorry, meant that it should be fixed in 2.3.2-pre2
I have checked this issue with X.F 2.3.4-pre1 and its working fine.
Hence closing this issue.