I don't know why they decided to set default value for Mode
to OneTime
But that's not what I want most of the time. It wasted my whole day in debugging.
Is there a way to set OneWay
value as default for Mode
of x:Bind
?
<!--This will not listen to future changes. it is OneTime by default-->
<TextBlock Text="{x:Bind Name}"/>
<!--We have to explicitly define Mode value-->
<TextBlock Text="{x:Bind Name, Mode=OneWay}"/>
starting in Windows 10, version 1607 (Anniversary Update), SDK version 14393 you can set
on any of the parent xaml elements and the default will persist for children of that node that haven't explicitly set the
Mode
property.Here you can read more about it.
I think it's by design. If you want to use OneWay as as default value. You could use Binding
For now, the Binding should be stronger than X:Bind.
TL:DR: No it's not possible to change the binding mode on the built-in controls.
x:Bind
together with a few other markup extensions likex:Phase
were all added to increase performance. Keep in mind that UWP applications can run on desktops, but also on the smallest IoT devices, so performance is key.First of all,
x:Bind
is a compiled binding. During compilation the XAML is converted to strongly typed code behind, which is faster than the runtime object inspection used by{Binding}
.Second, it's optimized for performance by itself, using
OneTime
binding.OneWay
andTwoWay
bindings requires infrastructure to watch and push back changes.In the past everything used to be
OneWay
with{Binding}
, implying a small performance hit on every single field, even those that had to be bound only once (because why would you bother changing toOneTime
if it just works). Now you're forced to think which fields should be update-able and thus use more resources.More info on x:Bind on MSDN.