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.
For all VisualElement objects, the PropertyChanged event is called *BEFORE* the Style is applied to the object.
This means that any attempts to get properties within the PropertyChanged method will not work.
var label = new Label();
label.PropertyChanged += (sender, args) =>
if (args.PropertyName == "Style" || args.PropertyName == "TextColor")
Console.WriteLine(label.TextColor == Color.Red);
label.TextColor = Color.Red;
label.Style = new Style(typeof(Label))
Property = Label.TextColorProperty,
Value = Color.Blue
The StyleProperty is constructed with a BindableProperty.PropertyChanged delegate (which refers to the VisualElement.OnStylePropertyChanged method).
However, within the BindableObject.SetValueActual method, BindableProperty.PropertChanged is called *AFTER* BindableObject.OnPropertyChanged.
Should be fixed in 2.1.0-pre1
The fix won't be in the next release as it was breaking multiple other stuffs.
As always, with events with multiple handlers, the order matters, and the order that's fine for one is probably not for others.
When you receive the PropertyChanged event, you can be sure that the property has changed. There's is no guarantee that the property is fully applied. It's a bit like when you set the Text of a Label, the PropertyChanged event is fired as soon as the property has changed, but that doesn't mean the Layout has adapted yet to the new size of the Label.
We might consider changing that in the future, but it's too much of a breaking change for all of our users right now.
Thanks for understanding this.
the xf team