[#VS2015] x:Bind, better performance and typed bindings in #Windows10 apps

Hello!

If you work with XAML for sure you know the label x:Binding, we usually use it to associate code behind properties with XAML views. With the arrival of Windows Universal Apps for Windows 10 to have an evolution of that tag x:Bind.

The way to use it is very similar. This is the Binding that we already know from WPF

image

and now we can also use

image

Reading a little about this new label (see references below), I see that it improves performance at runtime (something that we always appreciate). To achieve this, it generates strongly typed code to manage the bindings. This brings us to an interesting scenario: “have the ability of validating our Bindings at compile time

This means that, if for example, we are associating the text of a TextBlock to a “Messages” property, if it does not exist in the class defined in the namespace “x:”, for they will be a compilation error.

image

Now, after knowing this, first thing I did was try to change all the Binding by Bind, and I learned a couple of things

  • The way in which Bind handles data types and Paths is slightly different, in some cases, not only is change Binding by Bind, but also specify the correct path to the object in the ViewModel
  • The Binding default mode is Mode=OneWay, and Bind is Mode=OneTime. If no specific mode you need in your XAML you can have some surprises

So well, I would recommend using Bind whenever possible. But if you already have code created with Binding, it is certainly necessary to test it before doing a massive update!

Greetings @ Madrid

-El Bruno

References

Advertisements

2 thoughts on “[#VS2015] x:Bind, better performance and typed bindings in #Windows10 apps

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s