XAML and runtime controls

On Windows Phone, which is better in terms of performance, define controls in XAML or dynamically create them at runtime? What is cons / pros for XAML and runtime controls?

+4
source share
4 answers

I remember that loading Xaml is more efficient than equivalent creation in code:

Factors that affect speed include the number of named elements (since they connect to code members using lookups in the constructor file) and the number of similar / total elements.

From a business perspective, keeping it in Xaml is a much simpler way to support a project. The whole goal of Xaml was to let designers work independently of coders.

+4
source

I think I'm right in saying that the Persian wise does not matter.

From the point of view of Dev, the presence of controls defined in XAML provides a clear separation, and if you use MVVM, you get all the benefits that the template brings (unit testing, clear separation, improved manageability, etc.).

In addition, if you have controls defined in XAML, your application will be better at developing Blend and allow you to visually visually control the appearance of your application.

I prefer to store all the user interface controls in XAML, and also make nuts and bolts in the code .. but the structure is designed to suit all tastes of dev

+1
source

I think that if you try to define animation / VisualStates using clean code, you will realize how great Blend can be.

The Binding syntax is also not very readable in the code, but then it can be a matter of taste.

+1
source

The difference in performance is negligible and should not even be a factor, because the difference in the quality of service and the quality of the code is so great. The code-generated controls are a nightmare to support, complex in design and style, and it is more difficult for developers to keep track of the flow of applications. You basically wonder about the difference between using XAML, which can provide a view of development time, a separate presentation logic from business logic, and allows you to use tools like Blend, compared to a software approach that overrides all of the above. What if you decide to go to Windows 8 and use the WinRT mechanism? With a XAML approach and a template such as MVVM, you can probably reuse the bulk of your code and just update some of the views, while with a programmatic approach all this code will need to be destroyed in favor of a new runtime. Therefore, even if there was a slight difference in performance between one, the other, I would suggest, it does not matter, because other factors are much more important to consider.

+1
source

All Articles