On my Compiled Bindings considerations article, I wrote about the differences between regular bindings (Binding) and the UWP compiled bindings (x:Bind).
The most important bit to keep from that article is the fact that the default binding Mode
for regular bindings is OneWay
, while for the compiled ones is OneTime
.
Best way to understand this is with some sample code:
<StackPanel>
<!-- the implicit binding mode here is "OneWay" -->
<TextBlock Text={Binding Name} />
<!-- the implicit binding mode here is "OneTime" -->
<TextBlock Text={x:Bind Name} />
</StackPanel>
Starting Windows 10 version 1607 (Anniversary Update, SDK version 14393), developers can change the default binding Mode
by setting the x:DefaultBindMode attribute.
Applying the attribute to an element will make it and all child elements use the same value for binding mode.
Here’s the same sample code again, now with the x:DefaultBindMode
attribute added to the root element:
<StackPanel x:DefaultBindMode="OneWay">
<!-- the implicit binding mode here is "OneWay" -->
<TextBlock Text={Binding Name} />
<!-- the implicit binding mode here is "OneWay", as set on the x:DefaultBindMode in the parent element -->
<TextBlock Text={x:Bind Name} />
</StackPanel>