Xamarin.Forms 3.1 introduced BindableSpan 👍.
As part of that work is was suggested that the default BindingMode be set to OneTime because OneTime bindings are cheaper.
I would like to start a discussion, and propose switching the default binding mode to be OneWay for the Span.TextProperty. There are also the other Color
properties on Span as well that are currently defaulting to OneTime. I would also suggest that these be changed as well; however that is a much smaller concern.
I do realize that I can set the Mode on all of my Span's Bindings to be OneWay and get the behavior I am describing. However, this issue is not about saving a few keystrokes. It is about lost development time, trying to debug binding issues that arise from unexpected behavior.
I am also aware that there was at least one other issue raised, where this unexpected default caused a problem.
First I would like to make the case, that in general if I am applying a {Binding}
to a Span OneWay is the most common use case. Broadly speaking there are only two common sources for the {Binding}
.
Currently it looks as if the only performance gains from using BindingMode.OneTime come when compiling your XAML. I do not want to downplay the importance of compiled XAML or the performance gains from not needing to create and emit those handlers; compiled XAML is the default and I typically see it as the default starting point. However, unless I am missing something, at run time (assuming non-compiled XAML or items created in code) there is little difference between a OneWay and OneTime binding. From this perspective, the performance gains do not seem worth the loss of the time and functionality. Have I missed anything here?
For what it is people familiar with other XAML frameworks will also likely expect OneWay (minimum) binding as a default. I am hesitant to use the words "XAML Standard" but the spirit of it is here. Changing the default binding mode to OneWay will align with what is already done in the other frameworks.
{Binding}
to OneWay, except in the case the TextProperty. x:Bind
x:Bind
is coming for Xamarin.Forms. With it, I would suggest, comes the opportunity to reset developer's Binding expectations. In UWP "{x:Bind}
defaults to OneTime; {Binding}
defaults to OneWay". Those already familiar with UWP XAML know this, and I would suggest that keeping Xamarin.Forms inline with this pattern will help meet developer's expectations.
@adamped
@jassmith
I raised this issue initially as I saw this problem coming. Its hard to know that its defaulted to something different and the performance gains, are likely to be unnoticeable in most apps between OneWay and OneTime.
I'm all for setting it to OneWay.
Agreed.
Just hit this same problem and was just about to raise this same issue.
It should be consistent with the default mode for Labels.
If the performace gain is important enough for Spans then it should be as important for Labels.
Either way, I think they should be consistent with each other.
Most helpful comment
I raised this issue initially as I saw this problem coming. Its hard to know that its defaulted to something different and the performance gains, are likely to be unnoticeable in most apps between OneWay and OneTime.
I'm all for setting it to OneWay.