Improving App’s performance using compile time binding in Universal Windows App.

Improving App’s performance using compile time binding in Universal Windows App.

Windows 10 Universal Apps has come up with a new binding approach called compile time binding (x:Bind) where the property gets bind to the UIElement during compile time. In previous versions of windows Apps, the binding occurs during the runtime and its completely based on the reflections. This caused the reduction in apps performance.

bind0

lets see in detail about the compile time binding.

Create a simple page with just a TextBlock binding to a property called Title (which don’t exist).

<TextBlock Text="{x:Bind Title}" />

and now try to compile the app and the app displays a compile time error as shown below.

Bind1

 

But if the same property is used with Binding, the build gets successes and the during run time the app tries to find the property which is binded and try to get the value which leads to reduce apps performance.

By default the mode of x:Bind is OneTime, so the developer has to specify the mode of the property to Either OneWay or TwoWay based on the requirement. But in Binding the default mode is OneWay. Not all the Bindings in the App can be replaced with the x:Bind, there are some limitations with this.

The are two other scenarios that are good to take a note, when the x:Bind is used in a DataTemplate then the developer should specify the data type for the DataTemplate with x:DataType in the in order to make the App compile successfully, if not a compile time error is displayed.

bind2

One more thing  to be noted, if the x:Bind is used in the ResourceDictionary then the developer has to specify the Class file for the ResourceDictionary. Normally a ResourceDictionary doesn’t have a code behind file associated with it and also it doesn’t have a class name. In order for x:Bind expressions to be compiled, the ResourceDictionary must be given a class name and have a corresponding code behind file.

Hope this might Help.

Arun Kumar

Arun kumar Surya Prakash, is a  Developer  Consultant. He  is a Microsoft Certified Solution  Developer  for Store App Development, and a Azure Solution Developer. His core skills is on developing Windows Store App and Cross Platform App development. You can follow him @arunnov04

2 Comments to “Improving App’s performance using compile time binding in Universal Windows App.”

Comments are closed.