1.

Explain the different types of resources available in WPF.

Answer»

Resources can be classified into two types:  

  • Static Resource: Resources with this type are only evaluated once at the time of XAML loading. Resources that are static are evaluated only once, and if they change after that, those CHANGES aren't reflected in the binding. They can't be modified at runtime and REMAINS the same (static) throughout the life of the application.
  • Dynamic Resource: This is a resource that we use when we need to change the value of a property during execution. It is evaluated each time the resource is needed. When you change the CODE behind a resource, the elements that refer to it as a dynamic resource will ALSO change.

Example: If you implement "bitmapImageResource" as a static resource, it will remain the same, even if the source of the image is CHANGED. However, if you use "textForeColorResource" as a dynamic resource and change its color at runtime, then any element which references this resource will be affected. 



Discussion

No Comment Found