Google News
logo
WPF Interview Questions
WPF stands for Windows Presentation Foundation. It is the latest presentation API by Microsoft Windows. WPF is a 2D and 3D graphics engine. It's a re-invention of a UI for Desktop applications using WPF. Apart from dropping controls on "Windows Forms" just as developers have been doing for years, WPF provides an extra rapid boost to the application development including Rich User Interface, Animation and much more.
 
In a nutshell the following things can be done using WPF :
 
* Draw normal controls and graphics.
* Can create and animate 3D graphics.
* Can easily load/play audio and video files.
* Transforming objects including shapes, controls and video.
* Can easily draw vector graphics that scale without jagged aliasing.
* Can provide smooth graphical effects such as drop shadows and color gradients.
* Can use shared styles which can be used across the same controls to provide the same theme, skin and design.
WPF has following capabilities :
 
* It has all the equivalent common user controls like buttons, checkboxes, sliders etc.
* It has all the capabilities of HTML and Flash.
* It supports fix and flow format document.
* It provides the facility of data binding, animation and multimedia.
Windows Presentation Foundation (WPF) resources provide a simple way to reuse commonly defined objects and values. Resources in WPF allow you to set the properties of multiple controls at a time. For example, you can set the background property on several elements in a WPF application using a single resource.
 
The best way of defining the resources is on a Window or Page element level. Any resource that you define for an element also applies to their child elements of that element. For example, if you define a resource for a Window element that has a Grid as a child element, then the resources defined for the window elements can also be used by the grid element. However, if you define a resource for the grid element, then the resource applies only to the child elements of the grid element.
 
Syntax for resources in WPF :
<elementName propertyName="{markupExtension keyName}">

   <!-Content -->

</elementName>
 
Where,
 
* elementName : Name of the element that uses the resource.
* propertyName : Name of the property that takes its value from the resource.
* markupExtension : Define type of resource.
* keyName : key name of the resource, which is unique string to identify the resource.

There are two types of resource, namely,
 
* Static Resource
* Dynamic Resource
There are two types of resource, namely :
 
* Static Resource
* Dynamic Resource
 
Static Resource :
 
We should use the StaticResource markup extension to define the resource as a static resource. The value of StaticResource is determined at the time of loading.
 
Let's have a sample program, Add the below code snippet in Window1.xaml file inside the Grid.
<Grid.Resources>
   <SolidColorBrush x:Key="lblbgcolor" Color="
Blue"/>
</Grid.Resources>
<Label Name="lbl" Margin="71,44,77,0" Background="{StaticResourcelblbgcolor}" Height="49" />

 

Above code, Grid control uses the Resources property (<Grid.Resources>) to define resource. SolidColorBrush resource named lblbgcolor defined. lblbgcolor resource is used to set the background property of lable.


Dynamic Resource :
 
Dynamic Resource we use in a situation where we want to change the value of property at run time.
 
Let's have a sample program, Add the following code snippet in Window1.xaml file inside the Window element.
<Window.Resources>
   <SolidColorBrush x:Key="brush" Color="
Red" />
</Window.Resources>
<Button x:Name="btn" Content="Click Me" Click="Button_Click" Background="{DynamicResource brush}" Height="100" Width="100" />
 
Open code behind and add the following code snippet.
private void Button_Click(object sender, RoutedEventArgs e)
{
   this.btn.SetResourceReference(BackgroundProperty, "brush");
}
In the above code, Window control uses the Resources property (<Window.Resources>) to define resource. SolidColorBrush resource named brush defined. Brush resource is used to set the background property of button.
 
You can change the alignment of text in text boxes and buttons using content alignment. The content of content controls can be controlled by a number of properties in WPF. Two of these properties are:  
 
* HorizontalContentAlignment
* VerticalContentAlignment

System.Windows.Controls.Control, the parent class for all WPF controls, defines these properties. 
 
Example : 
Suppose you want to create a UI (User Interface) with a Button and TextBox. The default vertical/horizontal alignment of a button's content is center, while the default vertical/horizontal alignment of a TextBox is top and left, as shown below. 

Content Alignment
But what if you want TextBoxes and Button contents positioned differently? Let's say you want to place the content of the Button and TextBox right and bottom, respectively. 
 
VerticalContentAlignment and HorizontalContentAlignment properties are set to bottom and right, respectively, in the following code. 
<Grid Name="StackPanel1" Background="LightGray" >   
  <Button Name="Button1" Background="LightBlue" Height="45"   
     Content="Click Me!" Margin="23,12,159,0" VerticalAlignment="Top"   
     FontSize="16" FontWeight="Bold"   
     VerticalContentAlignment="Bottom" HorizontalContentAlignment="Right" />   
  <TextBox Height="50" Margin="26,72,74,0" Name="textBox1" VerticalAlignment="Top"   
     Text="I am a TextBox" FontSize="16"   
     VerticalContentAlignment="Bottom" HorizontalContentAlignment="Right" />   
</Grid>
It produces output similar to that shown below. You can see that the content in the TextBox and Button are aligned to the right and bottom, respectively. 

Content Alignment
MVVM (Model View ViewModel) is a framework for making applications in WPF. MVVM is the same as the MVC framework. It is a 3-tier architecture plus one more layer. We can do loose coupling using MVVM.
 
MVVM was introduced by John Gossman in 2005 specifically for use with WPF as a concrete application of Martin Fowler's broader Presentation Model pattern. The implementation of an application, based on the MVVM patterns, uses various platform capabilities that are available in some form for WPF, Silverlight Desktop/web, and on Windows. Many commercial applications, including Microsoft Expression products, were built following MVVM.
 
Advantage of MVVM
 
* Modularity
* Test driven approach.
* Separation UI and Business layer as view and view model.
* Code sharing between pages and forms.
* Easy to Maintain.


List of features of MVVM
 
* It separates the business and presentation layers, like MVP and MVC.
* Improve Structure/separation of concerns (View, ViewModel and Model).
* Enable a better Design/Developer Workflow.
* Enhance simplicity and testability.
* Enabled by the robust data binding capability of XAML.
* No need to use a code behind file (minimalist code-behind file).
* Provides application development ability for multiple environments.
* Powerful Data Binding, command, validation and much more.
* The designer and developer can work together.
The View is the client interface, input-output interface or the user interface. It collects all the user interface elements of the window, navigation page, user control, resource file, style and themes, custom tools and controls. The view is unaware of the ViewModel and the Model, and vice versa the ViewModel and Model is unaware of the View and control is tightly decoupled.
 
But the view model is aware of the needs of the view. They communicate by data binding and a dependency property or properties.
 
ViewModel in MVVM
 
ViewModel is a non-visual class. The MVVM Design Pattern does not derive from any WPF or Silverlight based class. The ViewModel is unaware of the view directly. Communication between the View and ViewModel is through some property and binding. Models are connected directly to the ViewModel and invoke a method by the model class, it knows what the model has, like properties, methods etcetera and also is aware of what the view needs.
 
One View-Model can connect to multiple models, work like a one-to-many relationship and encapsulate business logic and data for the View. A ViewModel inherits some interface like INotifyPropertyChanged, icommand INotifyCollectionChanged etcetera.

ViewModel

One of the major differences is that .NET framework is required for running WPF browser applications on the client machine. But Silverlight runs using only the plug-in. Another point of difference is that applications made in WPF depend on the OS as .NET Framework only runs on Windows. On the other hand, the Silverlight plug-in can be installed on those OSs also, which are not Windows.
XAML is a declarative XML based language. It facilitates you to define objects and properties in XML. Its documents are loaded by XAML parser.
XAML is used to describe the objects, properties and their relation in between them. It makes you able to create any type of objects i.e. graphical and non-graphical.
Syntax :
<elementName propertyName="{markupExtension keyName}">  
   <!-Content -->  
</elementName>   
Here,
 
elementName : Name of the element that uses the resource.
 
propertyName : Name of the property that takes its value from the resource.
 
markupExtension : Define type of resource.
 
keyName : key name of the resource, which is unique string to identify the resource.
It is an object in AutoCAD, which is a collection of connected line, curved or straight. You can use this object to draw a polyline within some given points.
Silverlight WPF
Silverlight is based on smaller or larger compact CLR but not with a full breadth WPF is based on Off Desktop CLR with the full version.
User can create only in Browser-based Applications (XAP) User can create in XBAP Application, Navigation App, and Windows App
It supports Direct and Bubbling routed events. It supports 3 types of routed events Direct, Tunnel, and Bubbling.
It does not support Multi-binding. It supports Multi-binding.
It supports XML Data provider. It supports XML and Objects Data provider.
In Object-Oriented Design patterns, the command pattern is one of the strongest design patterns. A command pattern refers to a design pattern that uses an object to encapsulate information required for triggering an action or event later. Method name, an object that owns the method, and the parameters of the method are among the information included here. In situations where you need to execute operations based on user requests, the command pattern is the best approach to manage objects.
 
 
WPF's command design pattern consists of the following members :
 
Client : Creates a command object and sets its receiver.

Invoker : Request command object to perform an action.

Command : Defines the Execute operation.

Concreate Command : Invokes the Execute operation on the receiver.

Receiver : Executes the action requested.
In WPF, triggers are commonly used in Style and Control Templates. The visual effect of a WPF element is changed by triggers when a property or data changes or when an event takes place. The WPF trigger is a very important feature that allows us to modify the visual effect of controls or elements. Therefore, you are able to dynamically modify the appearance and/or behaviour of your control without creating a new one. 
 
Triggers can be divided into three categories :  
 
Property Triggers : A change in one property will cause an animated or immediate change in another property.

Data Triggers : Data triggers are triggered when certain conditions are met by bound data.

Event Triggers : These triggers take action when a specific event occurs.
Prism (Composite Application Guidance for WPF and Silverlight) is designed to build applications in WPF and Silverlight that have a single code base. It helps to develop the client application in a modular fashion so that complexity of a large application can be divided into simpler modules.
 
In other words “Prism is developed by Microsoft Patterns and Practices and provides guidance designed to help you to more easily design and build rich, flexible and easy-to-maintain Windows Presentation Foundation (WPF) desktop applications.”.
 
Architecture : The following diagram shows basic architecture :

Architecture

App.XAML :
Call Boot Strapper on Application_Startup.

BootStrapper : This is a class file that calls Shell (Shell.XAML) and so creates catalogue of module.

Shell : This is like a Master Page having regions.

Region : It is like placeholders to register views.

View : This is XAML file having User Interface

Module : Each module can have one or more View(s) which are registered to Region (in the Shell) through Region Manager.
GUI elements are arranged in an application by layout panels. In the event that you design your controls on fixed coordinates, the application model will not work if you move it to a different environment with different resolutions. As a result, layout panels are necessary to ensure that your control fits different screen sizes. WPF offers the following layout panels:  
 
* Stack Panel
* Virtualizing Stack Panel
* Grid Panel
* Canvas Panel
* Dock Panel
* Wrap Panel 

Consequently, these panels are easy to use, versatile, and extensible enough to meet the needs of most applications.
XAML (Extensible Application Markup Language) UI elements can be defined/resolved using the xmlns and xmlns:x namespaces. As the default namespace, xmlns aids in resolving all WPF elements. XAML language definitions are resolved using the xmlns:x namespace. This is prefixed by the “x:” character. 
 
xmlns Example : 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x Example : 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
A good example is the XAML snippet below, in which there are 2 elements - "StackPanel" and "X:name". A "StackPanel" element is resolved using the default namespace and an "x:name" element using the "xmlns:x" namespace. 
<StackPanel x:Name="myStack" />
Freezable objects are special types of objects with two states i.e., unfrozen and frozen. Objects in a frozen state cannot be modified, whereas objects in an unfrozen state can be modified as normal objects. Freezables provide observers with a Changed event that indicates any modifications to the object. When an object is frozen, it no longer needs to handle change notifications, which can improve its performance. Freezables can be shared across threads when they're frozen, but they can't be shared when they're unfrozen. Brushes, transformations, geometries, pens, and animations are some examples of freezable objects.
Objects in a 'frozen' state cannot be altered anytime. 
 
Let's consider a brush in a frozen state. What happens when we modify it? 
SolidColorBrush myBrush = new SolidColorBrush(Colors.Blue; 
myBrush.Freeze(); // Make the brush non-modifiable. 
myBrush.Color = Colors.Green; // Attempting to modify frozen brush

As shown below, it throws an InvalidOperationException :
 
InvalidOperation

XAML (Extensible Application Markup Language) is used by WPF to build user interfaces for Windows applications. XAML files are very powerful, but parsing them at runtime is rather expensive. Therefore, the MarkupCompiler converts XAML into BAML (Binary Application Markup File), which is a more compact binary version.

BAML files can be generated from XAML files with the '.BAML’ extension and embedded into .NET Framework assemblies as resources. BAML is a compressed declarative language that loads and parses faster than XAML.
They are :
 
* Stack Panel
* Grid Panel
* Canvas Panel
* Dock Panel
* Wrap Panel
It is used whenever a requirement for creating custom user interface arises. It is a drawing object, which gives instructions for making an object. These instructions include opacity etc. of the drawing. The Visual class also bridges the functionalities of WPF managed classes and the MilCore.dll.
The major subsystems are :
 
* Windows.Controls.Control
* Windows.DependancyObject
* Windows.FrameworkElement
* Windows.Media.Visuals
* Object
* Threading.DispatcherObject
* Windows.UIElements
A value converter acts as a bridge between a target and a source and it is necessary when a target is bound with one source, for instance you have a text box and a button control. You want to enable or disable the button control when the text of the text box is filled or null. In this case you need to convert the string data to Boolean. This is possible using a Value Converter. To implement Value Converters, there is the requirement to inherit from I Value Converter in the System.Windows.Data namespace and implement the two methods Convert and Convert Back.
No. Page controls Window controls
1. Page controls preside over the hosted browsers applications. Window controls preside over windows application.
2. Page controls cannot contain window control. Window controls may contain page control.
StaticResource DynamicResource
StaticResources evaluate the resource one time only. DynamicResource evaluates the resources every time they are required.
StaticResource is light. DynamicResource is heavy due to frequently evaluated.
MVC MVVM
Stands for Model View Controller
Stands for Model View ViewModel
An Architectural pattern which is used for developing UI that divides an application into three interconnected parts such as Model, View, and Controller
A software Architectural pattern used for separation of Development of GUI and the development of Business Logic and back-end logic 
The model represents Data, View represents UI, and Controller handles requests
The model represents objects, View represents UI layer, and ViewModel describes the binding between View and model 
It was used by java springs  and ASP.NET
It was used by WPF, Angular JS, and Silverlight
A - Anywhere execution ( Windows or Web)
 
B - Bindings ( less coding)
 
C - Common look and feel ( resource and styles)
 
D - Declarative programming (XAML)
 
E - Expression blend animation ( Animation ease)
 
F - Fast execution ( Hardware acceleration)
 
G - Graphic hardware independent ( resolution independent)
 
I would strongly suggest you see the below video which explains all the above A to G points practically.
XBAP is the abbreviated form of XAML Browser Application. It allows WPF applications to run inside web browsers. Installation of .NET framework on the client machine is a prerequisite for running WPF applications. But hosted applications are not given full admission to the client’s machine and are executed in a sandbox environment. Using WPF, such applications can also be created, which run directly in the browser. These applications are called XBAP.
ListBox is configured to scroll on an item-by-item basis by default. This is dependent on the height of each element and the scrolling action, thus, giving a rough feeling. Better way is to configure scrolling action so that it shifts items by a few pixels irrespective of their height. This is done by setting the ScrollViewer.CanContentScroll property to “false”. This will, however, make the ListBox lose the virtualization property.
There are three types of Routed events in WPF. They are :
 
Direct : This event can only be raised by the element in which it was originated.

Tunneling : This event is first raised by the element in which it was originated and then it gets raised by each consecutive container in the visual tree.

Bubbling : This event is first raised by the uppermost container in the visual tree and then gets raised by each consecutive container lying below the uppermost one, till it reaches the element it where it was originated.
Displaying “Hello World.
<page xmlns= '' ''>
  <TextBlock>
     Hello, World!
  </TextBlock>
</Page>
Attached properties are basically Dependency Properties that allows the attachment of a value to any random object. Attached Properties (AP) are again a kind of Dependency Property (DP) in XAML. They can be used to receive a notification of a change of themself since they are a type of Dependency Property but one of the differences that these properties have is that they are not defined in the same class they used, unlike DPs.
 
* The type that defines the Attached Property is designed so that it can be the parent element of the elements that will set values for the Attached Property. The type then iterates its child objects using internal logic against some object's tree structure, obtains the values and acts on those values in some manner.
 
* The type that defines the Attached Property will be used as the child element for a variety of possible parent elements and content models.
 
* The type that defines the Attached Property represents a service. Other types set values for the Attached Property. Then, when the element that set the property is evaluated in the context of the service, the Attached Property values are obtained using internal logic of the service class.

APs are called “attached” properties because we can attach some behaviour to the control that is originally not expected from that control.
 
Example
 
Suppose I have a TextBox control and I want to extend its functionality to accept letters and special symbols but not numeric values.
 
The AP that I have defined in my class TextBlockExtension.cs is as in the following :
public static bool GetAllowOnlyString(DependencyObject obj)
{
    return (bool) obj.GetValue(AllowOnlyStringProperty);
}
public static void SetAllowOnlyString(DependencyObject obj, bool value)
{
    obj.SetValue(AllowOnlyStringProperty, value);
}
// Using a DependencyProperty as the backing store for AllowOnlyString. This enables animation, styling, binding, etc...
public static readonly DependencyProperty AllowOnlyStringProperty = DependencyProperty.RegisterAttached("AllowOnlyString", typeof (bool), typeof (TextblockExtension), new PropertyMetadata(false, AllowOnlyString));
private static void AllowOnlyString(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
    if (d is TextBox)
    {
        TextBox txtObj = (TextBox) d;
        txtObj.TextChanged += (s, arg) =>
        {
            TextBox txt = s as TextBox;
            if (!Regex.IsMatch(txt.Text, "^[a-zA-Z]*$"))
            {
                txtObj.BorderBrush = Brushes.Red;
                MessageBox.Show("Only letter allowed!");
            }
        };
    }
}
In the code, as we can see, the AP has the default value of False, in other words we need to provide the APs the value true wherever I want this functionality to work for the TextBox.
 
In my MainWindow.xaml.cs I have defined my TextBox as in the following :
<TextBox Width="200" Height="50" local:TextblockExtension.AllowOnlyString="True"></TextBox>
WCF (Windows Communication Foundation) : WCF is a Microsoft unified programming technology used for creating, configuring and deploying applications to a production environment for testing purposes. Developers can use it to create secure, reliable solutions that work across multiple platforms. It deals with the interoperability of distributed applications using the .NET framework. 

WPF (Windows Presentation Foundation) : WPF is a new form of .NET technology developed by Microsoft that is used to build desktop applications and high-fidelity experiences for Windows. A comprehensive set of built-in features are available in WPF, including controls, application model, data binding, layout, 2D and 3D graphics, animation, styles, templates, documents, resources, typography, etc., for application development.
WinForms (Windows Forms) : WinForms is Microsoft's GUI (Graphical User Interface) approach to the .Net Framework and was introduced in February 2002. It was the primary API for .NET used to build Windows applications until WPF and Silverlight were introduced. In order to develop a standalone application, only the runtime environment and OS (Operating system) are required.

WPF (Windows Presentation Foundation) : In 2007, Microsoft introduced WPF to replace WinForms in desktop application development for the .Net Framework. WPF is a UI framework designed for creating Windows or desktop applications. Currently, it is the latest Windows presentation API.

Difference between WPF and Winforms :

WPF Winforms
It is the latest concept for building desktop/windows applications.   This is the old way to build desktop applications for Windows.  
A markup language is used to design the UI, allowing complex user interfaces to be designed.  No markup language is used to design UI. Instead, event-driven controls are used. 
Comparatively to WinForms, it provides effective and fully supported data binding. In data binding, a connection is established between the application UI (User Interface) and the data that the application displays.  Although it offers data binding, it does so in a limited way, so it's less effective than WPF.   
Besides providing 2D and 3D vector capabilities, it also offers functionality such as rich, interactive, animated, hardware-accelerated functions.  In comparison to WPF, it does not provide rich, interactive, animated, hardware accelerated, vector 2D and 3D features.     
It is not easy to use WPF as it requires good knowledge of the controls.   When developing applications, Windows forms are more convenient. 
There is no limit to the customization of the UI, and the controls can be modified without difficulty since it is written from scratch.   It typically contains limited controls that are not easy to customize.  
This is an efficient approach when building an application that requires a variety of media types, creates a skinned user interface, binds to XML, and creates a desktop application that has a web-like navigation style.  When you want to develop a simple application with few modern features and more resources online, it is considered good.
WPF dependency properties are properties that extend the functionality of CLR (Common Language Runtime) properties. Dependency properties are those whose value is dependent on external sources (value from other inputs), such as animation, data binding, styles, themes, and user preferences, or visual tree inheritance. These properties provide self-contained validation, default values, monitoring of changed properties, and other runtime information. 
 
 
Advantages of Dependency Property :
 
* Dependency Property is not stored every time, but only when it is modified or changed. As a result, memory consumption is reduced.

* The DependencyProperty is notified whenever a property's value changes via INotifyPropertyChange. As a result, data binding becomes simpler since changes are immediately reflected in the value.

* Dependency Properties are capable of supporting animation, setting styles via style setters, and even providing control templates.
WPF templates define the overall visual appearance and look of a control. There is always a default template associated with each control, which determines how it looks. If you need to customize the visual behaviour of control or the visual appearance of it, you can easily create your own templates in WPF applications. Through data binding, the programming logic and the template can be connected.

Following is a list of four types of templates :   

Control Template :
It enables you to customize a control's appearance and behavior.

Data Template :
You can customize the look and feel of all your data objects with this.

ItemsPanel Template :
This template allows you to customize the layout of items in ItemControls such as ListBoxes and ListViews.

HierarchalData Template:
This template lets you customize the template of both the parent and child treeview items
In Path animations, an animated object follows a path set by a Path geometry. The PathGeometry property of the PathAnimation can be set by defining a geometric path. You can use path animations to animate objects along a complex path. A complex animation can be created by joining together straight lines, arcs, and Bezier curves in any order.
X: Key uniquely identifies elements that are created and referenced in an XAML defined dictionary. By adding an x: Key value to an XAML object element a resource in the resource dictionary can be identified and is the most common way to identify.
The Tab control is a common UI element that has been around for some time. It makes a convenient way to organize your window when there is more than could realistically fit and still be comprehensible. Tab Control is easier in Windows Presentation Foundation.
 
Two elements play main roles in building a tab control :
 
* TabControl and
* TabItem

TabControl is the container of one or more TabItem elements like as follows.
<TabControl>
   <TabItem Header="Tab 1">xyz</TabItem>
   <TabItem Header="Tab 2">abc</TabItem>
</TabControl>
In WPF, Tabs are very easy to implement. Create a new WPF Window, remove the default Grid tags, and add the following XAML:
<TabControl>
   <TabItem Header="Tab 1">xyz</TabItem>
   <TabItem Header="Tab 2">abc</TabItem>
</TabControl>
Clipping a region is a process of displaying partial area of a region by setting the outline of a region. In WPF, the clipping has been extended to all elements that are inherited from UIElement that includes controls, images, panels, Windows, and Pages.
<Window.Clip>
   <EllipseGeometry Center="150,160" RadiusX="120" RadiusY="120" />
</Window.Clip>
The following code snippet clips or crops an image to an ellipse.
<Image Source="Garden.jpg">
    <Image.Clip>
        <EllipseGeometry Center="150,160" RadiusX="120" RadiusY="120" />
    </Image.Clip>
</Image>
private void ClipImage()
{
    // Create a BitmapImage
    BitmapImage bmpImage = new BitmapImage();
    bmpImage.BeginInit();
    bmpImage.UriSource = new Uri(@ "C:\Images\Garden.jpg", UriKind.RelativeOrAbsolute);
    bmpImage.EndInit();
    // Clipped Image
    Image clippedImage = new Image();
    clippedImage.Source = bmpImage;
    EllipseGeometry clipGeometry = new EllipseGeometry(new Point(150, 160), 120, 120);
    clippedImage.Clip = clipGeometry;
    LayoutRoot.Children.Add(clippedImage);
}
This is a property on a binding that controls the data flow from a target to a source and used for two-way data binding. The default mode is when the focus changes but there are many other options available.
 
Properties available with UpdateSourceTrigger
 
Default : This is the default value and it means a lost focus for most of the controls.

LostFocus :
Value update will be on hold until the focus moves out of the control.

PropertyChanged :
Value update will happen whenever a target property changes. It usually happen on every keystoke.

Explicit :
Used to defer source updates until the user does it forcibly by the click of a button or so.

Default vs LostFocus
 
Default and LostFocus means the same thing for most of the controls with the exception of DataGrid. For DataGrid:
 
* Lost Focus : Cell lost focus
* Default : Row lost focus

Code :
<grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="50*" />
        <ColumnDefinition Width="50*" />
     </Grid.ColumnDefinitions>
    <TextBlock Text="Source:" Width="auto" />
    <TextBox Name="SourceText" Width="160" Height="30" Margin="48,0,44,82" />
    <TextBlock Text="Target:" Grid.Column="1" Width="auto" />
    <TextBox Name="TargetText" Width="160" Height="30" Text="{Binding ElementName=SourceText, Path=Text,UpdateSourceTrigger=Default}" Grid.Column="1" Margin="44,0,47,82" />
</grid>
Output :
 
When the user types into the source TextBox :

Output
Advantages :
 
* Tight multimedia integration: To use 3-D graphics, video, speech, and rich document viewing in Windows 32 or Windows Forms applications, you would need to learn several independent technologies and blend them together without much built-in support. WPF applications allow you to use all these features with a consistent programming model.
 
* Resolution independence: WPF lets you shrink or enlarge elements on the screen, independent of the screen's resolution. It uses vector graphics to make your applications resolution-independent.
 
* Hardware acceleration: WPF is built on top of Direct3D, which offloads work to graphics processing units (GPUs) instead of central processor units (CPUs). This provides WPF applications with the benefit of hardware acceleration, permitting smoother graphics and enhanced performance.
 
* Declarative programming: WPF uses Extensible Application Markup Language (XAML) declarative programming to define the layout of application objects and to represent 3-D models, among other things. This allows graphic designers to directly contribute to the look and feel of WPF applications.
 
* Rich composition and customization: WPF controls are easily customizable. You need not write any code to customize controls in very unique ways. WPF also lets you create skins for applications that have radically different looks.
 
* Easy deployment: WPF provides options for deploying traditional Windows applications (using Windows Installer or Click Once). This feature is not unique to WPF, but is still an important component of the technology.
 
* Culturally aware controls: Static text in controls and the return data for the String function are modified according to the culture and language specified by the end user's operating system.


Disadvantages : 
 
* WPF's in-box control suite is far more limited than that of WinForms.
 
* There's greater support in the 3rd-party control space for WinForms. (That's changing, but for now by advantage of time, WinForms has greater support in the community).
 
* Most developers already know WinForms; WPF provides a new learning curve.
 
* WPF will not run on Windows 2000 or lower.
 
* No MDI child mode.
The AccessText control in WPF converts a character preceded by an underscore to an Access Key. The Access Key is registered and therefore raises an event when pressed.
 
Creating an AccessText
 
The AccessText element represents an AccessText control in XAML. 
 
<AccessText>_Click Me</AccessText>
 
The following code snippet adds an AccessText to a Button control. The button control click event will be raised when you select the ALT+C keys on the keyboard.
<Button Name="Button1" Width="120" Height="50" Margin="33,70,59,124" FontSize="16" Click="Button1_Click">
    <AccessText>_Click Me</AccessText>
</Button>
If there are multiple underscore characters, only the first one is converted into an AccessKey; the other underscores appear as normal text. If the underscore that you want converted to the access key is not the first underscore, use two consecutive underscores for any underscores that precede the one that you want to convert.
Virtualization technique in WPF improves the rendering performance of UI elements. By applying virtualization, the layout system ensures that only the visible items of a container are rendered on the screen. For example, a list control may have thousands of items but virtualization will reduce the rendering to the visible items only.
 
VirtualizingStackPanel : The VirtualizingStackPanel control in WPF is used to implement virtualization.The IsVirtualizing property of the VirtualizingStackPanel activates the virtualization. By default, the IsVirtualizing property is set to true. When IsVirtualizing is set to false, a VirtualizingStackPanel behaves the same as an ordinary StackPanel.  
<VirtualizingStackPanel Width="300" Height="200" />
The VirtualizingStackPanel.VirtualizationMode property has two values, Standard and Recycling. The default value of VirtualizationMode is Standard and means that the VirtualizingStackPanel creates an item container for each visible item and discards it when it is no longer needed (such as when the item is scrolled out of view). When an ItemsControl contains many items, the process of creating and discarding item containers can degrade performance. In that case, using the Recycling reuses item containers instead of creating a new one each time.