• +91 9723535972
  • info@interviewmaterial.com

WPF Interview Questions and Answers

Related Subjects

WPF Interview Questions and Answers

Question - 11 : - What is the need of WPF when we had GDI, GDI+ and DirectX?

Answer - 11 : - First let’s try to understand how display technology has evolved in Microsoft technology.  User32:- This provides the windows look and feel for buttons and textboxes and other UI elements. User32 lacked drawing capabilities. GDI (Graphics device interface):- Microsoft introduced GDI to provide drawing capabilities. GDI not only provided drawing capabilities but also provided a high level of abstraction on the hardware display. In other words it encapsulates all complexities of hardware in the GDI API. GDI+:- GDI+ was introduced which basically extends GDI and provides extra functionalities like jpg and PNG support, gradient shading and anti-aliasing. The biggest issue with GDI API was it did not use hardware acceleration and did not have animation and 3D support. Note: - Hardware acceleration is a process in which we use hardware to perform some functions rather than performing those functions using the software which is running in the CPU.   DirectX :- One of the biggest issues with GDI and its extension GDI+ was hardware acceleration and animation support. This came as a biggest disadvantage for game developers. To answer and server game developers Microsoft developed DirectX. DirectX exploited hardware acceleration, had support for 3D, full color graphics , media streaming facility and lot more. This API no matured when it comes to gaming industry. WPF :- Microsoft almost had 3 to 4 API's for display technologies , so why a need for one more display technology. DirectX had this excellent feature of using hardware acceleration. Microsoft wanted to develop UI elements like textboxes,button,grids etc using the DirectX technology by which they can exploit the hardware acceleration feature. As WPF stands on the top of directX you can not only build simple UI elements but also go one step further and develop special UI elements like Grid, FlowDocument, and Ellipse. Oh yes you can go one more step further and build animations.WPF is not meant for game development. DirectX still will lead in that scenario. In case you are looking for light animation ( not game programming ) WPF will be a choice. You can also express WPF using XML which is also called as XAML.In other words WPF is a wrapper which is built over DirectX. So let’s define WPF.    WPF is a collection of classes that simplify building dynamic user interfaces. Those classes include a new set of controls, some of which mimic old UI elements (such as Label, TextBox, Button), and some that are new (such as Grid, FlowDocument and Ellipse).

Question - 12 : - What kind of documents are supported in WPF?

Answer - 12 : - There are two kind of major document supported in WPF Fixed format documents and Flow format document. Fixed format documents look like PDF format. They display content regardless of screen size and resolution. But flow format document adjust depending on screen size and resolution. Below is the code snippet for fixed format. You can see the document has a look of PDF reader. Step 1 defines the tag to define a document and Step 2 shows how the document looks.    Figure .3:- Document viewer in action

Question - 13 : - How can we access XAML objects in behind code?

Answer - 13 : - To access XAML objects in behind code you just need to define them with the same name as given in the XAML document. For instance in the below code snippet we named the object as objtext and the object is defined with the same name in the behind code.    Figure .2 Accessing XAML object

Question - 14 : - Can you explain how we can separate code and XAML?

Answer - 14 : - This is one of the most important features of WPF, separating the XAML from the code to be handled. So designers can independently work on the presentation of the application and developers can actually write the code logic independent of how the presentation is.    Figure .1:- XAML and behind code in action Above is the code snippet, which shows a XAML file and the code completely detached from the XAML presentation. In order to associate a class with XAML file you need to specify the x: Class attribute. Any event specified on the XAML object can be connected by defining a method with sender and event values. You can see from the above code snippet we have linked the MyClickEvent to an event in the behind code.

Question - 15 : - Are XAML file compiled or built on runtime?

Answer - 15 : - XAML files are usually compiled rather than parsing on runtime. But it also supports parsing during runtime. When we build a XAML based project, you will see it creates g.cs extension in obi\Debug folder. Therefore, for every XAMl file you will find a g.cs file. For instance, a Shiv.XAML will have Shiv.g.cs file in obi\Debug folder. In short, in runtime you actually do not see the XAML file. But if you want to do runtime, parsing of XAML file it also allows that to be done.

Question - 16 : - What is WPF?

Answer - 16 : -

WPF is the latest presentation API by Microsoft Windows. It is 2D and 3D graphic engine. Its capabilities include:-

  1. All the common user controls. For example, check boxes, buttons, sliders etc.
  2. Supports flow and fix format documents
  3. all the functionality of Flash and HTML
  4. Data binding
  5. Multimedia
  6. Animation

Question - 17 : - What are the types of documents supported by WPF?

Answer - 17 : -

Two types of the documents supported by Windows Presentation Foundation (WPF) are the Flow format and fixed Format document. Flow format document alters the content to fit the screen size while fixed format document present content irrespective of the screen size.

Question - 18 : - Name the namespace required for working with 3D.

Answer - 18 : -

The namespace required for working in 3D is System.Windows.Media.Medi3D.

Question - 19 : - Is it right to say that WPF has replaced DirectX?

Answer - 19 : -

No, WPF can never replace DirectX. WPF cannot be used to create games with stunning graphics. WPF is meant to be a replacement for windows form, not DirectX.

Question - 20 : - How can the size of StatusBar be increased proportionally?

Answer - 20 : -

By overruling the ItemsPanel attribute of StatusBar with a grid. The grid’s columns can be appropriately configured to get the desired result.


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners