Download PDF Your requested download is ready! Click
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 arent reflected in the binding. They cant 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 “bitmapResource” as a static resource, it will remain the same, even if the source of the 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.
1 Explain why we need WPF when we have windows forms.
A to G characters can better explain the need for WPF as follows:
A – Executable on any platform (Windows or Web)
B – Simple binding (no coding required)
C – Standardized look and feel (resources, styles, etc.)
D – Declarative programming (XAML)
E – Expression Blend animation (Animation easiness)
F – Hardware acceleration (Fast performance)
G – Hardware-independent graphics (independent of resolution)
2 What is the basic difference between Events and Commands in the MVVM Model?
Commands are more powerful and are advantageous to use instead of events. Actions are deeply connected with the event’s source and, therefore, the events cannot be reused easily. But commands make it possible to efficiently maintain multiple actions at one place and then reuse them as per our requirement.
What are the important features of MVVM?
The following are some of the features of MVVM:
MVVM allows your application architecture to be loosely coupled. A layer (Data layer, presentation layer, and domain layer) can be changed independently of others.
The Model, ViewModel, and View layers can each be extended separately without impacting the others.
One can write test cases for both the Model and ViewModel layers without referencing the View layer directly. As a result, it is easier to write unit test cases.
Enhanced system performance allows screens to load more quickly.
Code-behind files are not needed (minimalist code-behind files).
It is possible for designers and developers to work together.
Streamline the workflow for designers and developers.
UI and Business layers are separated as views and viewmodels respectively.
Make complex WPF applications easier to develop.
5 What are the four general kinds of XAML elements?
The four general kind of XAML elements are
Root Elements
Panel Elements
Control Elements
Geometric Elements
2 What is the INotifyPropertyChanged Interface?
The InotifyPropertyChanged notifies clients, generally those who are binding, if the value of a property gets changed. It has an event, called PropertyChanged, which gets raised everytime a property of Model object is changed.
1 How can elements in a ListBox be sorted?
Sorting can be done by using a property of the ItemsCollection object. ItemsCollection contains an attribute, SortDescriptions, which holds System.ComponentModel.SortDescription instances. Every SortDescription instance defines how the elements should be sorted and indicates if the sort is descending or ascending.
For instance, this code sorts elements of ContentControl on the basis of their word count property: