Explain the difference between static and dynamicresource? (.NET WPF interview questions)
- By Shiv Prasad Koirala in .Net
- Jan 26th, 2014
This question is taken from the .NET interview question with answer video series provided by www.questpond.com
Resources can be referred statically or dynamically. Static referred resources evaluate the resource only once and after that if the resources change those changes are not reflected in the binding. While dynamic referred resources are evaluated every time the resource is needed.
Consider the below "SolidColorBrush" resource which is set to "LightBlue" color.
<SolidColorBrush Color="LightBlue" x:Key="buttonBackground" />
The above resource is binded with the below two textboxes statically and dynamically respectively.
<TextBox Background="DynamicResource buttonBackground}" />
<TextBox Background="StaticResource buttonBackground}"/>
Now if we modify the resource , you see the first text box changes the background and the other textbox color stays as it is.
Below is the output of the same.
Below video explain what is WPF and how they differ from Windows form
Shiv Prasad Koirala
Visit us @ www.questpond.com or call us at 022-66752917... read more