Pages

Wednesday, April 11, 2012

WPF Interview Questions And Answers


 FREE Resume posting for the Job Seekers in this site, (This site is JobSeekers Social networking of resumes of you and your Frineds ) you can send your resume from  all over the world  with experience and qualification dont send the projects and personal details please write the heading ex: 3+ years of expe in IT to this mail id softwarewalkins@gmail.com. it is like naukri and monster

It is open database of the resumes if you have any objections dont send your resume.  send the resumes from all over the world  Advantage of this site is you can copy the your Resume link in the address bar and paste in your compose mail so u need not to upload the resume when u r applying for any post

FREE Job Requirement posting on www.allwalkin.blogspot.com. Please forward to softwarewalkins@gmail.com

 Do you have any material in any Technology in IT please send the soft copy to this mail id softwarewalkins@gmail.com


Do you any 
 

IT Interview Questions Please send your questions to us our readers will give the answers

send your questions to softwarewalkins@gmail.com send the answers to same email id 


WPF Interview Questions And Answers
Page 1
Ques: 1
What is a Freezable?
Ans:   A freezable object is one that has a mechanism that allows you to "Freeze" it. This locks downs all the state and makes the object immutable. This makes the object more performant to use and safer to share between threads.
 
Ques: 2
What is Path animation?
Ans: Path animation in which the object moves along the path specified by the Path geometry. As the animation progresses, it reads the X-axis, Y-axis and angle information from the path geometry and generates the output. These are useful when an object has to be animated along a complex path.
 
Ques: 3
What is the use of System.Windows.Media namespace?
Ans: This is the root namespace of several other media related namespaces. It provides different types to work with animations like 3D rendering, text rendering and other multimedia services.
 
Ques: 4
What are the core WPF assemblies?
Ans: The core WPF assemblies are,
 
WindowsBase.dll:- This is the core types constituting the infrastructure of WPF API.
 
PresentationCore.dll:- It defines numerous types constituting foundation of WPF GUI layer.
 
PresentationFoundation.dll:- It defines WPF control types, animation & multimedia support, data binding suport and other WPF services.
 
  Besides these three libraries WPF also uses an unmanaged binary called milcore.dll which acts as a bridge between WPF assemblies and DirectX runtime layer.
 
Ques: 5 How to define a button USING XAML?
Ans: To define a button in WPF using XAML, Syntax is given below-
 
<Button Name="btnName">btnCaption</ Button>
 
Example:-
 
<Button Name="btnClick">Click Me</Button>
 
 
Here the <Button> element specifies the use of the Button class.
 
Ques: 6
What is the use of System.Windows.Navigation namespace in WPF?
Ans: This namespace contains different classes for navigation between windows.
 
Ques: 7
Which namespace is used to work with 3D in WPF.
Ans: System.Windows.Media.Medi3D namespace is used for working with 3D.
 
Ques: 8
What is a Routed event?
Ans: In WPF application it contains many elements. These elements exist in an element tree relationship with each other. A routed event is a type of event that can invoke handlers on multiple listeners in an element tree, rather than just on the object that raised the event.
 
Ques: 9
Can you explain how we can separate code and XAML?
Ans:    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.
 
Ques: 10
What kind of documents are supported in WPF?
Ans:    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.
 
Ques: 11
What are dependency properties?
Ans: These dependency properties belong to one class but can be used in another.
Consider the below code snippet:-
 
 
<Rectangle Height="72" Width="131" Canvas.Left="74" Canvas.Top="77" />
 
 
Height and Width are regular properties of the Rectangle. But Canvas. Top and Canvas. Left is dependency property as it belongs the canvas class. It is used by the Rectangle to specify its position within Canvas.
 
Ques: 12
What is XAML extensible markup language?
Ans: XAML is an extensible markup language based on XML. XAML can be thought of as a declarative script for creating .NET 3.0 UI. It is particularly used in WPF as a user interface markup language to define UI elements, data binding, eventing and other features. It is also used in Windows Workflow Foundation (WF), in which the workflows themselves can be defined in XAML code.
 
Ques: 13
What is XBAP?
Ans: XBAP means XAML Browser Application. XBAP allows for WPF applications to be used inside a browser. For this .NET framework is required to be installed on the client system and hosted applications run in a partial trust sandbox environment.
 
Ques: 14 What is WPF?
Ans: Windows Presentation Foundation (WPF) is the presentation subsystem feature of the .NET Framework 3.0,that provide good design and advance controls. Silverlight is the Subset of WPF. Through WPF we can create Windows and WebBrowser Application.
 
 
Q1. What is WPF?
WPF stands for Windows Presentation Foundation. It is an application programming Interface for developing rich UI on Windows. WPF is introduced in .NET 3.0. By the use of WPF we can create two and three dimensional graphics,animations etc.
 
Q2. What is XAML and how it is related to WPF?
XAML is a new mark up language which is used for defining UI elements and its relationships with other UI elements. The XAML is introduced by WPF in .NET 3.0 WPF uses XAML for UI design.
 
Q3. Does XAML file compiled or Parsed?
By default XAML files are compiled ,But we do have options to let it be parsed.
 
Q4. What is the root namespace used for Animations and 3D rendering in WPF?
System.Windows.Media namespace.
 
Q5. What are the names of main asseblies used by WPF?
a)WindowsBase 
b)PresentationCore 
c)PresentationFoundation
 
Q6. What operating systems support WPF?
Following are the operating systems that support WPF 
a)Windows7 
b)Windows Vista 
c)Windows XP Service Pack 2 or later
 
Q7. Describe the types of documents supported by WPF?
There are two kinds of document supported by WPF 
a)Flow format:Flow format document adjusts as per screen size and resolution 
b)Fixed Format:Fixed Format document does not adjust as per screen size and resolution
 
Q8. What namespaces are needed to host a WPF control in Windows form application?
The following namespaces needs to be referenced : 
a)PresentationCore.dll  
b)PresentationFramework.dll 
c)UIAutomationProvider.dll 
d)UIAutomationTypes.dll 
e)WindowsBase.dll
 
Q9. What is Dependency Property In WPF?
Windows Presentation Foundation (WPF) has a set of services that is used to extend the functionality of a common language runtime property. These services are referred as the WPF property system. A property that is backed by the WPF property system is known as a dependency property
 
Q10.What is routed event in WPF?
A WPF user interface is constructed in a layered approach, where one visual element can have zero or more child elements. so we can visualise the elements tree for the full page. Routed events are a new feature provided by WPF which allows events to travel down the elements tree to the target element, or bubble up the elements tree to the root element. When an event is raised, it "travels" up or down the elements tree invoking handlers for that event on any element subscribed to that event it encounters en route.This tree traversal does not cover the entire elements tree, only the ancestral element chain between the root element and the element which is the target of the event.

What is WPF?

 
Windows Presentation Foundation (Avalon was the code name for WPF) is the new presentation API in WinFX. WPF is a two and three dimensional graphics engine. It has the following capabilities:- 
• Has all equivalent common user controls like buttons, check boxes sliders etc. 
• Fixed and flow format documents  
• Has all of the capabilities of HTML and Flash  
• 2D and 3D vector graphics  
• Animation  
• Multimedia  
• Data binding
 

What is XAML?

 
XAML (pronounced as Zammel) is a declarative XML-based language by which you can define object and properties in XML. XAML document is loaded by a XAML parser. XAML parser instantiates objects and set there properties. XAML describes objects, properties and there relation in between them. Using XAML, you can create any kind of objects that means graphical or non-graphical. WPF parses the XAML document and instantiates the objects and creates the relation as defined by XAML. 
So XAML is a XML document which defines objects and properties and WPF loads this document in actual memory.

What are dependency properties?

 
These dependency properties belong to one class but can be used in another.  
Consider the below code snippet:- 
  <Rectangle Height="72" Width="131" Canvas.Left="74" Canvas.Top="77" />  
 
Height and Width are regular properties of the Rectangle. But Canvas. Top and Canvas. Left is dependency property as it belongs the canvas class. It is used by the Rectangle to specify its position within Canvas.

Are XAML file compiled or built on runtime?

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.

Can you explain how we can separate code and XAML?

 
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.

How can we access XAML objects in behind code?

 
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

What kind of documents are supported in WPF?

 
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

What is the need of WPF when we had GDI, GDI+ and DirectX?

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). 

How does hardware acceleration work with WPF?

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. 
 
WPF exploits hardware acceleration in a two tier manner.
WPF API first detects the level of hardware acceleration using parameters like RAM of video card , per pixel value etc. Depending on that it either uses Tier 0, Tier 1 or Tier 2 rendering mode. 
 
Tier 0:- If the video card does not support hardware acceleration then WPF uses Tier 0 rendering mode. In other words it uses software acceleration. This corresponds to working of DirectX version less than 7.0. 
 
Tier 1:- If the video card supports partial hardware acceleration then WPF uses Tier 1 rendering mode. This corresponds to working of DirectX version between 7.0 and 9.0. 
 
Tier 2:- If the video card supports hardware acceleration then WPF uses Tier 2 rendering mode. This corresponds to working of DirectX version equal or greater than 9.0. 

Does that mean WPF has replaced DirectX?

No, WPF does not replace DirectX. DirectX will still be still needed to make cutting edge games. The video performance of directX is still many times higher than WPF API. So when it comes to game development the preference will be always DirectX and not WPF. WPF is not a optimum solution to make games, oh yes you can make a TIC TAC TOE game but not high action animation games. 
 
One point to remember WPF is a replacement for windows form and not directX. 

So can we define WPF in a precise way?

Windows Presentation Framework is the new presentation API. WPF is a two and three dimensional graphics engine. It has the following capabilities:- 
• Has all equivalent common user controls like buttons, check boxes sliders etc. 
• Fixed and flow format documents  
• Has all of the capabilities of HTML and Flash  
• 2D and 3D vector graphics  
• Animation  
• Multimedia  
• Data binding 

What is XAML?

XAML (pronounced as Zammel) is a declarative XML-based language by which you can define object and properties in XML. XAML document is loaded by a XAML parser. XAML parser instantiates objects and set their properties. XAML describes objects, properties and there relation in between them. Using XAML, you can create any kind of objects that means graphical or non-graphical. WPF parses the XAML document and instantiates the objects and creates the relation as defined by XAML. 
So XAML is a XML document which defines objects and properties and WPF loads this document in actual memory.

So is XAML meant only for WPF?

 
No,XAML is not meant only for WPF.XAML is a XML-based language and it had various variants. 
 
WPF XAML is used to describe WPF content, such as WPF objects, controls and documents. In WPF XAML we also have XPS XAML which defines an XML representation of electronic documents. 
 
Silverlight XAML is a subset of WPF XAML meant for Silverlight applications. Silverlight is a cross-platform browser plug-in which helps us to create rich web content with 2-dimensional graphics, animation, and audio and video. 
 
WWF XAML helps us to describe Windows Workflow Foundation content. WWF engine then uses this XAML and invokes workflow accordingly. 

Can you explain the overall architecture of WPF?

 
Above figure shows the overall architecture of WPF. It has three major sections presentation core, presentation framework and milcore. In the same diagram we have shown how other section like direct and operating system interact with the system. So let’s go section by section to understand how every section works. 
 
User32:- It decides which goes where on the screen. 
 
DirectX: - As said previously WPF uses directX internally. DirectX talks with drivers and renders the content. 
 
Milcore: - Mil stands for media integration library. This section is a unmanaged code because it acts like a bridge between WPF managed and DirectX / User32 unmanaged API. 
 
Presentation core ;- This is a low level API exposed by WPF providing features for 2D , 3D , geometry etc. 
 
Presentation framework:- This section has high level features like application controls , layouts . Content etc which helps you to build up your application.
 
 
There are ten important namespaces / classes in WPF. 
 
System.Threading. DispatcherObject  
All WPF objects derive from the DispatcherObject. WPF works on STA model i.e. Single Threading Apartment Model. The main duty of this object is to handle concurrency and threading. When any message like mouse clicks, button clicks etc are initiated they are sent to the DispatcherObject who verifies whether code is running on the correct thread. In the coming section we will look in to detail how WPF threading works. 
 System.Windows. DependencyObject
When WPF was designed property based architecture was considered. In other words rather than using methods, functions and events object behavior will interact using properties. For now we will only restrict ourselves to this definition. In the coming section we have dedicated question for the same. 
 System.Windows.Media.Visual 
 
Visual class is a drawing object which abstracts drawing instructions, how drawing should be drawn like clipping, opacity and other functionalities. Visual class also acts like a bridge between unmanaged MilCore.dll and WPF managed classes. When any class derived from visual it can be displayed on windows. If you want to create your own customized user interface then you can program using visual objects. 
 
System.Windows.UIElement 
 
UIElement handled three important aspects layout, input and events. 
System.Windows. FrameworkElement 
FrameWorkElement uses the foundation set by UIElement. It adds key properties like HorizontalAlignment , VerticalAlignment , margins etc. 
 
System.Windows.Shapes.Shape 
 
This class helps us to create basic shapes such as Rectangle, Polygon, Ellipse, Line, and Path. 
 
System.Windows.Controls. Control 
 
This class has controls like TextBox,Button,ListBox etc. It adds some extra properties like font,foreground and background colors. 
 
System.Windows.Controls. ContentControl 
 
It holds a single piece of content. This can start from a simple label and go down to a unit level of string in a layout panel using shapes. 
System.Windows.Controls. ItemsControl 
This is the base class for all controls that show a collection of items, such as the ListBox and TreeView.  
 
System.Windows.Controls.Panel 
 
This class is used for all layout containers—elements that can contain one or more children and arrange them as per specific layout rules. These containers are the foundation of the WPF layout system, and using them is the key to arranging your content in the most attractive, flexible way possible. 
 

Can explain the different elements involved in WPF application practically?

In order to understand the different elements of WPF, we will do a small ‘hello world’ sample and in that process we will understand the different elements of WPF. 
 
Note :- For this sample we have VS 2008 express edition. 
 
 So start VS 2008 express and from the templates select the WPF application as show in the below figure below. 
 
Once we have created the WPF application project you will see two file types one the XAML file and the other is the behind code i.e. XAML.cs. XAML files are nothing but XML files which has all the elements needed to display the windows UI. Every of the XAML elements maps to come class. For instance the ‘Window’ element maps to ‘WpfApplication1.Window1’ class , ‘Button’ elements in XAML file maps to ‘System.Windows.Control. Button’ class and ‘Grid’ XAML element is mapped to ‘System.Windows.Control.Grid’.
The ‘App.XAML’ and ‘App.XAML.CS’ are the entry point files. If we see the code for ‘App.XAML.CS’ you will see the reference to XAML file which needs to be loaded. So the first code which runs in the application is ‘void main()’ method from ‘App.XAML.CS’ which in turn loads the ‘Window1.XAML’ file for rendering.
We can now connect the behind code method and function to events in XAML file elements.
You can see from the above code snippet how the button element has the click event linked to the ‘MyButton_Click’ function. ‘MyButton_Click’ is the method which is in the XAML.CS behind code. 
So now if you run the code you can see the button and if you click on it you can see the message box for the same. 
 
 
These dependency properties belong to one class but can be used in another.  
Consider the below code snippet:-
<Rectangle Height="72" Width="131" Canvas.Left="74" Canvas.Top="77" />
 
Height and Width are regular properties of the Rectangle. But Canvas. Top and Canvas. Left is dependency property as it belongs the canvas class. It is used by the Rectangle to specify its position within Canvas.  
 

What is WPF?

 
Windows Presentation Framework is the new  
presentation API in WinFX. WPF is a two and three dimensional graphics engine. It has  
the following capabilities:-  
v Has all equivalent common user controls like buttons, check boxes sliders etc.  
v Fixed and flow format documents  
v Has all of the capabilities of HTML and Flash  
v 2D and 3D vector graphics  
v Animation  
v Multimedia  
v Data binding

What is XAML?

 
XAML (pronounced as Zammel) is a declarative XML-based language by which you can  
define object and properties in XML. XAML document is loaded by a XAML parser.  
XAML parser instantiates objects and set there properties. XAML describes objects,  
properties and there relation in between them. Using XAML you can create any kind of  
objects that means graphical or non-graphical. WPF parses the XAML document and  
instantiates the objects and creates the relation as defined by XAML.

what are dependency properties?

 
These are dependency properties that belong to one class but can be used in another.  
Consider the below code snippet:-  
<Rectangle Height="72" Width="131" Canvas.Left="74" Canvas.Top="77" />  
4 7 9  
Height and Width are regular properties of the Rectangle. But Canvas.Top and Canvas.  
Left is dependency property as it belongs the canvas class. It’s used by the Rectangle to  
specify its position within Canvas.

What is a Routed event?

 
In a typical WPF application, it contains many elements. These elements exist in an element tree relationship with each other. A routed event is a type of event that can invoke handlers on multiple listeners in an element tree, rather than just on the object that raised the event.

What are the core WPF assemblies?

 
The core WPF assemblies are,  
 
WindowsBase.dll:- It defines the core types constituting the infrastructure of WPF API.  
 
PresentationCore.dll:- Defines numerous types constituting foundation of WPF GUI layer.  
 
PresentationFoundation.dll:- It defines WPF control types, animation & multimedia support, data binding suport and other WPF services.  
 
Besides these three libraries WPF also uses an unmanaged binary called milcore.dll which acts as a bridge between WPF assemblies and DirectX runtime layer.

What is the use of System.Windows.Media namespace?

 
It is the root namespace to several other media related namespaces. It provides different types to work with animations, 3D rendering, text rendering and other multimedia services.

What is WPF?

 
Microsoft has introduced WPF(Windows Presentation Foundation) API in .NET3.0 framework for the first time. WPF merged all the unrelated APIs into a single unified object model. So if you want to use 3D graphics or multimedia for your application you do not use to need use different APIs. WPF provides all the functionalities you need to develop richer GUI applications.  
 
Using WPF we can develop GUI for both windows application and web application.

How to define a button USING XAML?

 
To define a button in WPD using XAML use the following syntax,
<Button Name="btnName">btnCaption</ Button>
 
 
Example:-
<Button Name="btnClick">Click Me</Button>
 
Here the <Button> element specifies the use of the Button class.

What is the use of "System.Windows.Markup" namespace in WPF?

 
The System.Windows.Markup namespace provides some helper classes for XAML code.

Which namespace provide classes for integration with WPF and Win32?

 
The "System.Windows.Interop" namespace provides classes for integration of WPF with Win32.

Which class of the WPF is the base class of all the user-interactive elements?

 
Select from following answers:
  1. Control
  2. Shape
  3. ContentControl
  4. Panel
 
Control class is the base class of all the user-interactive elements in WPF.

Which class is the base class of all the visual elements of WPF?

 
Select from following answers:
  1. Control
  2. Shape
  3. Visual
  4. Window Visual is the base class of all the visual elements of WPF.

Control class of WPF is derived from which class?

Select from following answers:
  1. Shape
  2. ContentControl
  3. FrameworkElement
  4. Window
 
Control class of WPF is derived from FrameworkElement class.

The core classes for User Interface is located in which namespace?

Select from following answers:
  1. System.Windows.Shapes
  2. System.Windows.Controls
  3. System.Windows.Automation
  4. System.Windows.Media
 
System.Windows.Shapes namespace defines UI classes like Line, Rectangle,etc.

Which namespace provide classes to work with images, sound, video, etc?

 
The System.Windows.Media namespace provide classes to work with images, sound, video, etc in WPF.

What is the use of System.Windows.Navigation namespace in WPF?

 
System.Windows.Navigation namespace contains different classes for navigation between windows.

What is 'One-way-to-Source ' binding property?

 
In One-way-to-Source binding when the target property changes, the source object gets updated.

Which namespace is used to work with 3D in WPF.

 
The System.Windows.Media.Medi3D namespace is used to work with 3D.

Which of these is not a class defined by System.Windows.Shapes namespace?

 
Select from following answers:
  1. Ellipse
  2. Polygon
  3. Polypath
  4. Line
Polypath is not the classs.Ellipse,Polygon,Line are the classes  
defined by this namespace
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Select from following answers:
  1. Pink
  2. Blue
  3. Yellow
  4. None of these
Yellow will be the backcolor as it has been specified. Pink is not applicable as it has not been attached with this Button

Which of the following is an event in WPF ?

 
Select from following answers:
  1. Bubbled
  2. Tunnelled
  3. Direct
  4. All of the Above
All of these events are supported in WPF.  
 
Bubbled: the path is from child to the parent control  
example: MouseRightButtonDown  
Tunnelled: the path is from parent to the child control.  
example: PreviewMouseRightButtonDown.  
Direct:The control itself receives the event  
eg:Click.

What are XBAP'S?

 
XBAP  
Xml Browser Applications:  
They are basically WPF applications which run with .xbap extension in the browser.Their main features are: 1)They provide a page based navigation model .Root tag is Page. In page based navigation, we can navigate from one .Xaml file to another by using the standard techniques like HyperLinks, NavigationService, and we are provided with back and forward buttons in the toolbar that appears in the output to visit the pages that have been opened using HyperlInk, NavigationService.  
2)They have restrictive permissions:  
example: we cannot do database connectivity, file handling or alter registries  
using XBAP's  
3)We can do animations, drawings, transforms apply brushes on XBPAP files.

Is it possible for a control to define a handler for an event, that the control can't itself raise?

 
Yes, It's is possible for a control to define a handler for an event, that the control can't itself raise.  
 
These incidents are called attached events.  
 
For example, a button controls in a grid. The button class defines a click event, but the grid class doest not. However, you can still define a handler for buttons in the grid by attaching the Click events of the button control.

What is the difference between User Settings and Application Settings in WPF?

 
The User Settings are Read/Write, they can be read or write even at runtime and can be saved.  
 
The Application Settings are read-only, they can only be written at design time.

which dll is also called as the engine of managed graphics?

 
Select from following answers:
  1. PresentationFramework.dll
  2. PresentationCore.dll
  3. milcore.dll
  4. none
 
milcore.dll:  
milcore.dll manages the display state.  
It paints the appropriate portions of the  
window as it is dragged around, covered and uncovered, minimized and restored, and so on.  
 
• PresentationFramework.dll holds the top-level WPF types, including those that represent windows, panels, and other types of controls.  
It also implements higher-level programming abstractions such as styles.  
Most of the classes used come from this assembly.  
 
• PresentationCore.dll holds base types, such as UIElement and Visual,  
from which all shapes and controls derive.
 
 
It is the technique through which one style aquires the features of another style  
 
It is implemented through BasedOn property of the Style class.  
 
example:
<Window x:Class="WpfApplication14jan. Window1"
 
    Title="Window1" Height="300" Width="300">
 
    <Window.Resources>
 
<Style x:Key="One" TargetType="{x:Type Button}">
 
        <Setter Property="Foreground"  Value="Green"/>
 
    </Style>
 
<!-- This is how the style inheritance is implemented-->   
 
<Style x:Key="Two" BasedOn="{StaticResource  One}" TargetType="{x:Type Button}">
 
        <Setter Property="Background" Value="Yellow"/>
 
    </Style>
 
    </Window.Resources>
 
    <Button Height="100" Width="100"  Style="{StaticResource Two}" Content="Welcome">
 
   </Button>
 
</Window>
 
 
//Note:  
//When you run the WPF Form, the Button will aquire the Formatting from both the  
//styles
 

Difference between x:Key and x:Name

 
x:Key and x:Name  
 
These are both the XAML attributes that are specified in the declaration of XAML elements.
  
 
x:Key:  
 
It is used mainly with the WPF Stylesheets or in ResourceDictionaries.
  
 
x is the namespace prefix  
Key is the element specified by the x namespace prefix  
 
x:Key is not applicable for user interface elements like the Button  
 
example:  
<Window x:Class="WpfApplication1. Window1"  
xmlns="http://schemas. microsoft.com/winfx/2006/xaml/ presentation"  
xmlns:x="http://schemas. microsoft.com/winfx/2006/xaml"  
Title="Window1" Height="300" Width="300">  
<Window.Resources>  
 
<Style x:Key="One" TargetType="{x:Type Button}">  
<Setter Property="Foreground" Value="Green"/>  
</Style>  
</Window.Resources>  
<!--how key is applied-->  
<Button Height="100" Width="100" Style="{StaticResource One}" Content="good"/>  
</Window>  
 
USES:  
 
using the Key element, we can refer the StyleSheet defined in <Style></Style> tag in some other  
 
<Style></Style> tag or in the declaration of some user interface element.  
 
In the above example, I have mentioned how Key is used to define the Style of a Button.
  
 
 
x:Name:  
 
It is used to mention the names of StyleSheets as well as the user interface controls  
example:  
<Button Height="100" Width="100" x:Name="mybutton" Content="good"/>  
 
x:Name can also be accessed in the code-behind (.xaml.cs /.xaml.vb), but x:Key cannot be accessed in code behind

How is mapping done between CLR namespaces and XAML namespaces?

 
Consider this XAML declaration
<Window x:Class="WpfApplication14jan. Window1"
    Title="Window1" Height="300" Width="300">
 
</Window>
 
The attribute xmlns="http://schemas. microsoft.com/winfx/2006/xaml/ presentation" is  
responsible for the mapping. Without this, no XAML user interface can be created  
or code executed.

How many predefined classes are there in the WPF Command Library?

 
Select from following answers:
  1. 5
  2. 4
  3. 2
  4. 6
 
5 classes are there:  
They are:-  
ApplicationCommands, NavigationCommands, MediaCommands, EditingCommands, and the ComponentCommands. These classes provide commands such as Cut, BrowseBack and BrowseForward, Play, Stop, Pause,AlignLeft,  
Moveleft, MoveRight without the overhead of extra code. These commands are represented by their  
properties.
 

Difference between MediaPlayer and MediaElement ?

 
MediaPlayer has no visual interface and not suitable to display videos. It cannot be placed on the XAML designer. It provides Media PlayBack for drawings. We have to use VideoDrawing or DrawingContext classes for that.  
example:  
MediaPlayer player = new MediaPlayer();  
player.Open(new Uri("c:\\intro.wmv", UriKind.Relative));  
VideoDrawing aVideoDrawing = new VideoDrawing();  
aVideoDrawing.Rect = new Rect(0, 0, 100, 100);  
aVideoDrawing.Player = player;  
player.Play();  
 
MediaElement has got visual interface and can easily display videos using its built in properties.  
It is designed for XAML use and can be placed on the XAML designer.

What is x:Code?

x:Code is a directive element defined in XAML.  
An x:Code directive element can contain inline programming code.  
The code that is defined inline can interact with the XAML on the same page.  
example:
<Window  x:Class="WpfApplication14jan. Window1"
    Title="Window1" Height="300" Width="300" Loaded="Window_Loaded">
<Grid Name="dd">
<Button Name="button1" Click="Clicked">In Line code!</Button>
<x:Code>
<![CDATA[
 
 void Clicked(object sender, RoutedEventArgs e)
 
{
 
button1.Content = "WPF Inline Code";
 
}
 
]]>
</x:Code>
</Grid>
 
    </Window>
 
Data Templates: Data Template visual representation of data in control with style. like List box.  
Control Templates: Control Template suppliers a visual representation of a UI Control like Button or List View.  
Items Panel Templates:Item Panel Templates uses when we want to show data in Hierarchical way like child object use under parent object.

What is the WPF Unit?

 
The WPF Unit is measured in DPI.  
 
First we need to understand about DPI and PX (i.e. Device Independent Pixels & Physical Pixels)  
 
1 DPI = 1/96 inch  
1 PX = 1/DPI - Depends on screen type  
The default system setting is 96 DPI  
 
Note: If the DPI increases, the number of physical pixels which compose one device independent pixel also increases. Hence, objects that have their sizes specified in device independent pixels get larger as the system DPI increases

What are the core WPF Assemblies that one should refer in a WPF application?

 
1) PresentationCore.dll: Visual rendering of low-level types UIElement.  
2) PresentationFramework.dll: Most of the common controls, and also support for data binding.  
3) WindowsBase.dll: Lower-level types like DependencyObject and DependencyProperty.

What is the Class Hierarchy in Windows Presentation Foundation?

 
* System.Threading. DispatcherObject class represents on object associated with a "Dispatcher".  
* System.Windows. DependencyObject class is the base class for classes that support dependency properties.  
* System.Windows.Media.Visual class is the base class for objects that can be rendered to a WPF window or page.  
* System.Windows.UIElement class defines core subsystems like Layout, Input, Focus and Events(LIFE).  
* System.Windows. FrameworkElement introduces data binding and data templates, styles and animation.  
* System.Windows.Controls. Control class adds a feature called templating. This is the base class for all the controls that the user interacts with.  
* System.Windows.Controls. ContentControl can hold a single nested element.
 
 
The different Data Binding Modes are:  
1) OneWay: The target is updated when the source changes.  
2) TwoWay: The target is updated when the source changes, and similarly, the source is updated when the target changes.  
3) OneWayToSource: Only the source is updated when the target changes.  
4) OneTime: The target is updated only the first time the source changes.

What is the importance of INotifyPropertyChanged in WPF?

 
* This interface contains a single event called "PropertyChanged" of the delegate type "PropertyChangedEventHandler".  
* To notify the WPF/Silverlight framework whenever the value of a property changes in an object, fire the event in the "set" accessor of the property.

What is the importance of INotifyCollectionChanged in WPF

 
* This interface is similar to INotifyPropertyChanged, which is to be implemented to notify the WPF/Silverlight framework whenever any changes occur in a collection, like adding an object or deleting an object.  
* "ObservableCollection" is a built-in class which implements the INotifyCollectionChanged interface.

What is Logical Tree in WPF?

 
* Logical tree describes the relations between elements of the user interface.  
* Every aspect of WPF (properties, events, resources, and so on) has behavior tied to the logical tree.  
* Logical tree is responsible for:  
1) Inherit Dependency Property values  
2) Resolving Dynamic Resources references  
3) Looking up element names for bindings  
4) Forwarding Routed Events  
* System.Windows. LogicalTreeHelper class is used to traverse the logical tree.

What is Visual Tree in WPF?

 
* Visual tree is an expansion of a logical tree, in which nodes are broken down into their visual components.  
* Visual tree contails all logical elements including all visual elements.  
* The elements that appear in a visual tree derive from 'System.Windows.Media.Visual' and 'System.Windows.Media. Visual3D'.  
* Visual tree is responsible for:  
1) Rendering visual elements  
2) Propagate element opacity  
3) Propagate layout and render transforms  
4) Propagate the 'IsEnabled' property  
5) Do hit-testing  
NOTE:  
* Visual tree is dependent on Windows theme.  
* Visual tree is empty until the window undergoes layout at least once. So it must be navigated in 'OnContentRendered' event handler.  
* System.Windows. VisualTreeHelper class is used to traverse the logical tree.

What is Dependency Properties and its Use in WPF?

 
* Dependency properties are used to enable styling, automatic data binding, templates, animation etc.  
* All types that want to use DependencyProperties must derive from 'DependencyObject' class.  
* The value of a DependencyProperty is resolved dynamically when read.  
* The value of a dependency property is stored in a dictionary of keys and values provided by 'DependencyObject' class.  
* Advantages:  
1) Reduced memory footprint  
2) Value Inheritance  
3) Change Notification

What are the Types of Resources in WPF?

 
1) Binary Resources  
Binary resources could be logo/image files, AV files etc.  
2) Logical Resources are of tow types:  
Static and Dynamic Resources  
* StaticResource finds the key defined within the ResourceDictionary under its scope during the Loading of the application.  
* Hence the Compiler will throw error during compilation if not found in resources.  
-- * DynamicResource Markup Extension defers the resource assignment to the actual runtime of the application.  
* So the expression remains unevaluated until the object being created.

What are Binary Resources in WPF?

* Binary resources could be logo/image files, AV files etc.  
* Resource files which are added to project, can have the “Build Action” defined on it from the file properties windows:  
- Resource : Embeds resource into the assembly (or culture specific satellite assembly)  
- Content : this leaves resource as loose file and upon compilation this resource information is not embedded to assembly. Instead, it adds custom attribute to the assembly ( AssemblyAssociatedContentFile) which records the existence and relative location of file.

What are Static Resources in WPF?

 
* StaticResource finds the key defined within the ResourceDictionary under its scope during the Loading of the application.  
* Hence the Compiler will throw error during compilation if not found in resources.

What are Dynamic Resources in WPF?

 
* DynamicResource Markup Extension defers the resource assignment to the actual runtime of the application.  
* So the expression remains unevaluated until the object being created.

What is the Choice between StaticResource and DynamicResource in WPF?

 
* StaticResource requires less CPU during runtime, so it is faster.  
* StaticResource are created when the application loads. So making everything as StaticResource means slowing down the Application Load process.  
* When the resources are unknown during compilation, you can use DynamicResource.  
* DynamicResource are used when user interaction changes the look and feel of an object.

What are Triggers and its type in WPF?

 
* The WPF styling and templating model enables you to specify Triggers within your Style.  
* Essentially, Triggers are objects that enable you to apply changes when certain conditions (such as when a certain property value becomes true, or when an event occurs) are satisfied.  
* Types of triggers:  
1) Property triggers get active when a property gets a specified value.  
2) Data triggers get active when a specified event is fired.  
3) Event triggers get active when a binding expression reaches a specified value.

What are Templates and its type in WPF?

 
* A Template is used to change how a control looks.  
* Types of templates:  
1) Control template: How a control is rendered and behaves by specifying the visual structure and behavioral aspects.  
2) Data template: To specify the visualization of data objects.  
3) Hierarchical data template: Used over hierarchical structure like TreeView and Menu.

What is application object and its reponsiblity?

 
* Application is a class that represents a WPF application running as a standalone client application in Windows.  
* Each running application contains at most a single instance of Application.  
* The Application object is defined in the App.xaml file and is responsible for:  
- Managing application lifetime (e.g. responding to startup/shutdown events)  
- Window, property and resource management  
- Command-line processing  
- Navigation

What is the Application Lifetime in WPF?

 
The main events fired from Application include:  
* Startup - Application is starting up.  
* Exit – Fired when an application is shutting down.  
* Activated – Fired when an application gets focus, i.e. becomes the foreground application  
* Deactivated – Fired when application loses focus, i.e. is no longer the foreground application  
* DispatcherUnhandledException – Fired when an exception is thrown, but not yet handled. You can choose to handle the exception or not  
* SessionEnding – Fired when Windows is being shut down–due to either logoff or Windows shutdown. You can cancel the shutdown sequence.  
* You can add custom code for any of these events by just overriding the OnEventName method in your Application-derived class, e.g. OnStartup.

What is the series of Window Events at Startup in WPF?

 
* At application startup, the Window events that are fired (in order) for the main window are:  
1) Initialized - Main window is being created  
2) IsVisibleChanged - IsVisible property set to true  
3) SizeChanged - Size property set to size of window  
4) LayoutUpdated - Window layout changes  
5) SourceInitialized - Window is attached to Win32 window handle  
6) Activated - Window becomes foreground window  
7) PreviewGotKeyboardFocus - Window getting focus  
8) IsKeyboardFocusWithinChanged - IsKeyboardFocusWithin property set to true  
9) IsKeyboardFocusedChanged - IsKeyboardFocused property set to true  
10) GotKeyboardFocus - Window now has keyboard focus  
11) LayoutUpdated - Window layout changes  
12) Loaded - Window is now laid out, fully rendered  
13) ContentRendered - All window content has been rendere

What is the series of event fired for application shutdown in WPF?

 
1) Closing - Window is going to close  
2) IsVisibleChanged - IsVisible property set to false  
3) Deactivated - Window becomes background window  
4) IsKeyboardFocusWithinChanged - IsKeyboardFocusWithin property set to false  
5) IsKeyboardFocusedChanged - IsKeyboardFocused property set to false  
6) LostKeyboardFocus - Window no longer has keyboard focus  
7) Closed - Window is closing

How to Creating Windows Forms Controls Dynamically in WPF?

1) Import the following namespaces:  
using System.Windows.Forms;  
using System.Windows.Forms. Integration;  
2) Create the windows forms control and set its properties and event handlers.  
3) Add the control to the 'Child' property of 'WindowsFormsHost' object.  
4) Add the host object to the 'Children' collection of the panel.

How to host WPF Controls in Windows Forms?

1) Add reference to the following:  
a) Presentation Core  
b) Presentation Framework  
c) WindowsBase  
d) WindowsFormsIntegration  
e) System.Xaml  
2) Also add reference to the WPF control DLL.  
3) Use the 'ElementHost' control in 'WPF Interoperability' tab in Toolbox to host WPF controls.
  
                

No comments:

Receive All Free Updates Via Facebook.