Thursday 8 November 2012

WPF(Windows Presentation Foundation) Questions & Answers

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 assemblies used by WPF?
a)Windows Base
b)Presentation Core
c)Presentation Foundation

Q5. What operating systems support WPF?
Following are the operating systems that support WPF
a) Windows 7
b) Windows Vista
c) Windows XP Service Pack 2 or later

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

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

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

Q9. 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 visualize 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.

Thursday 20 September 2012

WCF Interview Questions and Answer

Hi guys,
Here I'm attaching some basic interview questions that we commonly face in WCF(Windows Communication Foundation) interviews now a days.

Q1. What is WCF?
WCF stands for Windows Communication Foundation. It is a Software development kit for developing services on Windows. WCF is introduced in .NET 3.0. in the System.ServiceModel namespace. WCF is based on basic concepts of Service oriented architecture (SOA)

Q2. What is endpoint in WCF service?
The endpoint is an Interface which defines how a client will communicate with the service. It consists of three main points: Address,Binding and Contract.

Q3. Explain Address,Binding and contract for a WCF Service?
Address:Address defines where the service resides.
Binding:Binding defines how to communicate with the service.
Contract:Contract defines what is done by the service.

Q4. What are the various address format in WCF?
a)HTTP Address Format:--> http://localhost:
b)TCP Address Format:--> net.tcp://localhost:
c)MSMQ Address Format:--> net.msmq://localhost:

Q5. What are the types of binding available in WCF?
A binding is identified by the transport it supports and the encoding it uses. Transport may be HTTP,TCP etc and encoding may be text,binary etc. The popular types of binding may be as below:
a)BasicHttpBinding
b)NetTcpBinding
c)WSHttpBinding
d)NetMsmqBinding

Q6. What are the types of contract available in WCF?

The main contracts are:
a)Service Contract:Describes what operations the client can perform.
b)Operation Contract : defines the method inside Interface of Service.
c)Data Contract:Defines what data types are passed
d)Message Contract:Defines wheather a service can interact directly with messages

Q7. What are the various ways of hosting a WCF Service?
a)IIS b)Self Hosting c)WAS (Windows Activation Service)

Q8. What is the proxy for WCF Service?

A proxy is a class by which a service client can Interact with the service.
By the use of proxy in the client application we are able to call the different methods exposed by the service


Q9. How can we create Proxy for the WCF Service?

We can create proxy using the tool svcutil.exe after creating the service.
We can use the following command at command line.
svcutil.exe *.wsdl *.xsd /language:C# /out:SampleProxy.cs /config:app.config

Q10.What is the difference between WCF Service and Web Service?
a)WCF Service supports both http and tcp protocol while webservice supports only http protocol.
b)WCF Service is more flexible than web service.

Q11.What is DataContract and ServiceContract?Explain 
Data represented by creating DataContract which expose the
data which will be transefered /consumend from the serive
to its clients.

**Operations which is the functions provided by this
service.

To write an operation on WCF,you have to write it as an
interface,This interface contains the "Signature" of the
methods tagged by ServiceContract attribute,and all methods
signature will be impelemtned on this interface tagged with
OperationContract attribute.

and to implement these serivce contract you have to create
a class which implement the interface and the actual
implementation will be on that class.

Code Below show How to create a Service Contract:

CODE:
[ServiceContract]
Public Interface IEmpOperations
{
[OperationContract]
Decimal Get EmpSal(int EmpId);
}

Class MyEmp: IEmpOperations

{
Decimal Get EmpSal()
{
// Implementation of this method.
}

Hope this is useful for you guys..

Tuesday 7 August 2012

DATE FUNCTIONS In SQL Server


Hi all, This article is about Date Functions in Sql Server.

----Today
SELECT GETDATE() 'Today'
----Yesterday
SELECT DATEADD(d,-1,GETDATE()) 'Yesterday'
----First Day of Current Week
SELECT DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0) 'First Day of Current Week'
----Last Day of Current Week
SELECT DATEADD(wk,DATEDIFF(wk,0,GETDATE()),6) 'Last Day of Current Week'
----First Day of Last Week
SELECT DATEADD(wk,DATEDIFF(wk,7,GETDATE()),0) 'First Day of Last Week'
----Last Day of Last Week
SELECT DATEADD(wk,DATEDIFF(wk,7,GETDATE()),6) 'Last Day of Last Week'
----First Day of Current Month
SELECT DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0) 'First Day of Current Month'
----Last Day of Current Month
SELECT DATEADD(ms,- 3,DATEADD(mm,0,DATEADD(mm,DATEDIFF(mm,0,GETDATE())+1,0))) 'Last Day of Current Month'
----First Day of Last Month
SELECT DATEADD(mm,-1,DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0)) 'First Day of Last Month'
----Last Day of Last Month
SELECT DATEADD(ms,-3,DATEADD(mm,0,DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0))) 'Last Day of Last Month'
----First Day of Current Year
SELECT DATEADD(yy,DATEDIFF(yy,0,GETDATE()),0) 'First Day of Current Year'
----Last Day of Current Year
SELECT DATEADD(ms,-3,DATEADD(yy,0,DATEADD(yy,DATEDIFF(yy,0,GETDATE())+1,0))) 'Last Day of Current Year'
----First Day of Last Year
SELECT DATEADD(yy,-1,DATEADD(yy,DATEDIFF(yy,0,GETDATE()),0)) 'First Day of Last Year'
----Last Day of Last Year
SELECT DATEADD(ms,-3,DATEADD(yy,0,DATEADD(yy,DATEDIFF(yy,0,GETDATE()),0))) 'Last Day of Last Year'
 
----First Day of Current Quarter
SELECT DATEADD(qq, DATEDIFF(qq,0,GETDATE()), 0)
----Last Day of Current Quarter
SELECT DATEADD(ms,-3,DATEADD(qq, DATEDIFF(qq,0,GETDATE())+1,0))
----First Day of Prior Quarter
SELECT DATEADD(qq, DATEDIFF(qq,0,GETDATE())-1, 0)
----Last Day of Prior Quarter
 SELECT DATEADD(ms,-3,,DATEADD(qq, DATEDIFF(qq,0,GETDATE()), 0))

ResultSet:

Today
———————–
2008-08-29 21:54:58.967
Yesterday
———————–
2008-08-28 21:54:58.967
First Day of Current Week
————————-
2008-08-25 00:00:00.000
Last Day of Current Week
————————
2008-08-31 00:00:00.000
First Day of Last Week
———————–
2008-08-18 00:00:00.000
Last Day of Last Week
———————–
2008-08-24 00:00:00.000
First Day of Current Month
————————–
2008-08-01 00:00:00.000
Last Day of Current Month
————————-
2008-08-31 23:59:59.997
First Day of Last Month
———————–
2008-07-01 00:00:00.000
Last Day of Last Month
———————–
2008-07-31 23:59:59.997
First Day of Current Year
————————-
2008-01-01 00:00:00.000
Last Day of Current Year
————————
2008-12-31 23:59:59.997
First Day of Last Year
———————–
2007-01-01 00:00:00.000
Last Day of Last Year
———————–
2007-12-31 23:59:59.997 

These are the commonly used date functions in sql server.

Monday 11 June 2012

Interview Questions on Windows Presentation Foundation(WPF):

Q 1) What is WPF?
Q 2) What is XAML?
Q 3) What is XBAP?
Q 4) How can I override the Logical Tree?
Q 5) How can I enumerate all the descendants of a visual object?
Q 6) How can I create Custom Read-Only Dependency Properties?
Q 7) How can I use Dependency Property MetaData?
Q 8) How can I register the default value of the State dependency property to be false?
Q 9) What is Attached Properties and how to register it?
Q 10) How can I set an attached property in code?
Q 11) What is a Routed event?
Q 12) How can I handle the input event through XAML?
Q 13) How can I use an application resource?
Q 14) What are the requirements for a property to be animated?
Q 15) How do I trigger an animation when the data in the control is changed?
Q 16) What is Path animation?
Q 17) What is a Freezable?
Q 18) How can I determine whether a Freezable Is Frozen?
Q 19) How can I obtain a writable copy of a Read-Only Freezable?
Q 20) What is Commanding in WPF?
Q 21) How do I create a CommandBinding using a RoutedCommand?
Q 22) How can I add a CommandBinding to a window using markup?
Q 23) When I try to add multiple controls to a button it shows an error, how do I add multiple controls to a button?
Q 24) How placing controls in a WrapPanel differs from a Grid?
Q 25) How can I restrict the use of style?
Q 26) How can I create an extended style?
Q 27) How can I set a ControlTemplate?
Q 28) How can I create a custom WPF button whose look and feel depends on the Windows desktop theme currently in use? How do I get notified when the user changes the theme?
Q 29) What are the limitations of Inline Styles and Templates?
Q 30) How can I map CLR Namespaces to XML Namespaces in an Assembly?
Q 31) Which namespace is used to associate namespace identifiers with element names? Is there any effect on the attributes?
Q 32) What is the use of x:code?
Q 33) What way can a custom class can be defined in XAML?
Q 34) How can I apply the TypeConverter Attribute?
Q 35) How can I create Four Button controls with the contents set to a String, a DateTimeObject, an UIElement and A Panel that contains other UIElement objects?
Q 36) Can I create a ContentTemplate and apply the template to a ContentControl?
Q 37) How can I create a ControlTemplate for a HeaderedItemsControl?
Q 38) How can I make a style for a ContentControl so that the control has an enhanced visual appearance?
Q 39) How can I get an enumerator to the ContentControl's logical child elements?
Q 40) How do I create a Borderless Window in WPF?
Q 41) How can I animate a BorderThickness value?
Q 42) How can I use Event Trigger to control a StoryBoard after it is started?
Q 43) How do I add controls to Panel Content Model type of controls?
Q 44) How can I store a given document in a specific format using CreateSerializerWriter methods?
Q 45) How can I use MemoryStream to create a deep clone of a serializable object?
Q 46) How can I do versioning using Custom Serialization?
Q 47) How can I Match Annotations with Annotated Objects?
Q 48) How can I create an application that is used to declare a Context Menu with routed commands that the users can access to create and manage annotations?
Q 49) How can I define three paragraphs under one section?
Q 50) How can I use the BlockUIContainer element to host UIElement objects within Flow content?
Q 51) Can I embed a figure into a paragraph of text?
Q 52) How can I programmatically print XPS Files?
Q 53) How can I create a combine hard and soft shadow?
Q 54) How can I use a DoubleAnimation to rotate the textblock?
Q 55) What is the order in which the controls are rendered?
Q 56) How do I enumerate child objects in a visual tree?
Q 57) How rendering in WPF differs from WIN32 applications?
Q 58) When an animation is applied, the property value gets overwritten. How do we prevent the value of property?
Q 59) Performance gets reduced even after navigating away from a page that contains animation. How do we handle this issue?
Q 60) How do I apply an animation without using a storyboard?
Q 61) How do I apply BitmapEffect to a particular area of an Image?
Q 62) How do I apply Transform when an event is occurred?
Q 63) In what way CombinedGeometry is used?
Q 64) What are the properties that reduce the performance of a 3D graphics?
Q 65) How lights are useful in 3D graphics?
Q 66) How do I change the location of a model?
Q 67) How HitTest methods in VisualTreeHelper is useful?
Q 68) How do I use DrawingVisual object?
Q 69) What is an adorner?
Q 70) Where can adorners be used?
Q 71) How to add a custom adorner?
Q 72) How do I bind an Adorner to an Element?
Q 73) How do I remove the Adorner from an element?
Q 74) Where can I find information about guidelines to be followed while designing Stylable controls?
Q 75) What are the different models for Control authoring?
Q 76) What is the use of a ControlTemplate?
Q 77) How to access elements that are embedded inside the ControlTemplate?
Q 78) How do I build an ItemsControl ControlTemplate?
Q 79) How to edit templates using Microsoft Expression Blend?
Q 80) How to get the default template of a control programmatically?
Q 81) How to use binding in XAML?
Q 82) What is the use of the RelativeSource property?
Q 83) What is DataContext? How is it used?
Q 84) Can ItemControl's Items and ItemsSource properties be modified simultaneously?
Q 85) How do I filter Items in an ItemControl when the ItemControl's ItemsSource is set to a datasource?
Q 86) What are the uses of BindingModes?
Q 87) How do I update the source as I type in a TextBox?
Q 88) When an XMLDataProvider can be used? What are it's specific uses?
Q 89) How does TwoWay BindingMode work in an XMLDataProvider?
Q 90) In what way is an ObjectDataProvider useful?
Q 91) How to pass a parameter to a constructor using ObjectDataProvider?
Q 92) How to pass a parameter to a function using ObjectDataProvider?
Q 93) How can I bind a method and pass a parameter to the method?
Q 94) How to Get or Set a value that indicates whether to include the DataErrorValidationRule?
Q 95) What are the objects involved in DragandDrop?
Q 96) How do I create a DataObject?
Q 97) How do I retrieve data from a DataObject?
Q 98) What is Serialization?
Q 99) How to write an IsolatedStorage to an XML file?
Q 100) How do I serialize objects to a binary file?
Q 101) What are the three types of Localizability Attributes and how to use them?
Q 102) How can I set the Language property to the current user's UI language?
Q 103) How can I set the substitution property by overriding the default substitution?
Q 104) How can I specify in the .proj file whether to leave the free-form localization comments in the assembly using LocalizationDirectivesToLocFile tag?
Q 105) How can I add localization comments to an XAML file?
Q 106) Can I override the default categories for platform controls in XAML as well?
Q 107) How can I automatically layout Grids Using the IsSharedSizeScope Property?
Q 108) How does ClickOnce deployment work?
Q 109) Can I add prerequisites in my ClickOnce deployment?
Q 110) How do I enable automatic updates for my application using ClickOnce deployment?
Q 111) What is the difference between Frame and NavigationWindow?
Q 112) How does Rendering work in Frame control?
Q 113) Can I add dynamic HTML content to a Frame control?
Q 114) Are XAML Browser Applications OS independent?
Q 115) When I run an XBAP application, I get Application Deployment Error. What do I do to overcome this error?
Q 116) How to navigate between pages in an application?
Q 117) How to set content of a NavigationWindow?
Q 118) How do I handle Back and Forward button click?
Q 119) How do I pass data between pages in a NavigationWindow?
Q 120) How do I add registry entries in a setup project?
Q 121) How do I deploy shared components?
Q 122) How launch conditions are useful and how to add one to a setup project?
Q 123) How do I create a child window in WPF?
Q 124) How do I host Windows Forms control in a WPF Window?
Q 125) Does WPF support MDI?
Q 126) How can I write Message Loops?
Q 127) How can I HwndSource Treats ComponentDispatcher Events?
Q 128) How can I set the Owner property of the WPF window to the handle of our main form using helper class?
Q 129) How can I use Windows Forms in a WPF application?
Q 130) How do I host a Windows Forms control in a WPF application?
Q 131) How can I leverage my current investment in Windows Forms applications and still tap into the cool features of WPF?
Q 132) How can I host a Windows Forms Composite Control in Windows Presentation Foundation?
Q 133) How do I host a WPF control in a Windows Forms application?
Q 134) How can I Host the WPF UserControl in Windows Forms?
Q 135) What is the procedure to host the WPF content in Win32 window?
Q 136) Will you provide a tool to convert Windows Forms applications to WPF applications?
Q 137) What about user controls and third-party controls including ActiveX controls?
Q 138) Where do I find System.Windows.Forms.Integration?
Q 139) Can I use a WindowsFormsHost element to host a System.Windows.Forms?
Q 140) How do I assign full trust to an XBAP application?
Q 141) I am able to access the registry using full trust XBAP application in debug mode, when hosted in an intranet, the application gets crashed. What do I do?
Q 142) How do I get a custom defined permission set of an XBAP application?
Q 143) How to get data from database in XBAP application?
Q 144) Does permission set of partial trust change in the Local Intranet and Internet?
Q 145) How do I detect permission for a file in a partial trust application?
Q 146) Can a WPF application be designed using Microsoft Expression Blend?
Q 147) How do I add animations using Microsoft Expression Blend?
Q 148) How do I add custom controls to an application using Microsoft Expression Blend?
Q 149) What is ZAM3D?
Q 150) What are the file formats supported by ZAM3D?
Q 151) Can an XAML file created using ZAM3D be used with Visual Studio.NET?
Q 152) What is XAMLPAD?
Q 153) Does XAMLPAD support custom controls?
Q 154) Can we see the output of an XAML using XAMLPAD?
Q 155) Can I delay the display of a ToolTip?
Q 156) How can I use the ToolTipService properties to specify the position of a tooltip whose content is not a ToolTip object?
Q 157) Can I use the BetweenShowDelay Property?
Q 158) How can I make a TextBlock editable when it is clicked and the value is committed when ESC or ENTER is pressed?
Q 159) How do I prevent the user from changing the selected tab page in a TabControl?
Q 160) How do I dynamically hide and unhide tabs in a TabControl?
Q 161) How do I make the tabs in a TabControl appear on the bottom instead of the right?
Q 162) How can I add a style to a TabItem that is used in the TabControl?
Q 163) How can I create a ProgressBar and use an animation to simulate the progress of an operation?
Q 164) How can I make the text changed by itself during progress?
Q 165) How can I create and display a PrintDialog?
Q 166) How do I display the PrintPreview as a maximized window and control it's zooming?
Q 167) How can I animate a Popup?
Q 168) How can I specify a Custom Popup Position?
Q 169) How do I format numbers, dates and currencies in a TextBox?
Q 170) How do I make a TextBox use all upper-case (or lower-case) characters?
Q 171) How do I support browsing for a text file and reading it into a TextBox?
Q 172) How can I use the attached properties of Canvas to position child elements?
Q 173) How do I fill a ComboBox with the available fonts?
Q 174) How do I bind the values of an enum to a ComboBox?
Q 175) How do I bind a string array with a ListBox?
Q 176) How do I display items in a ListBox horizontally?
Q 177) How do I create custom layout for StatusBar items?
Q 178) How do I determine which button in a ToolBar is clicked?
Q 179) How can I apply a Style to a Menu control on a ToolBar?
Q 180) When I tab into a toolbar in WPF I can't tab out again ? What can I do to change this tab behavior?
Q 181) How do I make the Context Menu appear only when clicked at certain portions of the Control?
Q 182) How can I enable a Context Menu on a disabled Control?
Q 183) How can I create a shared Context Menu?
Q 184) How do I make the Context Menu to close after a set time interval?
Q 185) How can I create an Expander with a ScrollViewer?
Q 186) How can I bind the Expander's header element's Width to the ActualWidth of the Expander?
Q 187) How do I make the Expander button to be justified to the right, rather than the left which is the default?
Q 188) How can I replace the style of a DocumentViewer?
Q 189) How can I extend the style of a DocumentViewer?
Q 190) How can I DataBind DocumentViewer's Zoom Property to a TextBox?
Q 191) How to load an XPS document into the DocumentViewer?
Q 192) How can I load an XAML file into a FlowDocumentReader?
Q 193) How can I save the contents of a FlowDocumentReader as an XAML file?
Q 194) How can I create a GroupBox that has a title and a visible border that encloses it's content?
Q 195) How can I make sure that a GridSplitter Is visible?
Q 196) How can I create and use a GridLengthConverter Object?
Q 197) How can I convert an Image to grayscale?
Q 198) How can I crop an Image?
Q 199) Why does adding images to an ImageList in the Designer cause them to lose their alpha channel?
Q 200) How to rotate an image?
Q 201) How do I access / edit the metadata associated with an Image?
Q 202) How can the DrawVisual be used for rendering images?
Q 203) How do I enable the mnemonics (underlines) being displayed when an application is launched?
Q 204) How can I style a Separator used as a Menu Item?
Q 205) How can I use the member values of the enumeration to set the HorizontalScrollBarVisibility property of the ScrollViewer control?
Q 206) How can I use the Content-Scrolling Methods of ScrollViewer?
Q 207) How can I customize the Ticks on a Slider?
Q 208) Can I bind two sliders in two different windows?
Q 209) How do I add a hyperlink to a RichTextBox control?
Q 210) How do I create and save a RichTextFormat (RTF) file?
Q 211) How do I support drag-and-drop for a RichTextBox?
Q 212) How can I Save, Load, and Print RichTextBox Content?
Q 213) How can I animate the thickness of a border by using ThicknessAnimation?
Q 214) How can I use a BulletDecorator control that uses an image as the Bullet and a non-text element as the Child?
Q 215) How do I change the shape of the button to an ellipse?
Q 216) how to use WPF with ASP.NET 2008 (C#) with Demo.