In this section we will run through important WPF interview questions asked mmoonneeyy.info interviews. I know the list is not complete but wanted to. These questions are frequently asked in all IT companies. What is the need of WPF when we had windows forms?_text]A – Anywhere execution (Windows or Web) (Latest 50 WPF Interview Questions And Answers Pdf).
|Language:||English, Spanish, Portuguese|
|ePub File Size:||18.82 MB|
|PDF File Size:||11.74 MB|
|Distribution:||Free* [*Regsitration Required]|
1. What is WPF? WPF is the latest presentation API by Microsoft Windows. Top 70 WPF Interview Questions & Answers .. Download PDF. Wpf interview Question Answer - Free download as PDF File .pdf), Text File .txt) or read online for free. Wpf interview Question Answer will help to people. In this article you will learn about the most asked WPF Interview questions and answers.
You take data from some property or object or dependency property and bind it to another dependency property or object or else directly to an element. Draw Graphics and normal controls. To implement an IValueConverter one must create a class and then put the instance of that class in a ResourceDictionary within your UI. However, you can still define a handler for buttons in the grid by attaching the Click events of the button control. Path Get or Set the path to the source property of the Binding source.
It contains a XAML file and a code. UserControl cannot be styled or templated. All measurements are made in device-independent pixels, or logical pixels. These logical pixels are always mentioned as double, this enables them to have a fractional value too.
They are a special kind of FrameworkElement that provide visual clues to the user. They are also used to add handles to elements and give information about the state of a control.
Adorners are bound to the UIElement and are rendered on a surface that lies above the element, which is adorned. This surface is called an AdornerLayer. Adorners are mostly placed relatively to the bounded element. It allows WPF applications to run inside web browsers.
Installation of. Using WPF, such applications can also be created, which run directly in the browser. These applications are called XBAP. For this purpose, the ShowOnDisabled property can be used. It belongs to the ToolTipService class. 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. This will, however, make the ListBox lose the virtualization property.
This is because the applications are special-cased when they are compiled from XAML.
This results in the auto generation of a Main method. WPF is a presentation language. Windows services need specific permissions to execute some GUI related functions.
Therefore, if it does not get the required permissions, it gives errors. It has some important properties like IsSelected and IsHighlighted and also some necessary events like Selected and Unselected. ComboBoxItem is a content control and is thus very useful for adding simple strings to a ComboBox. The best way to do this is by setting it Name property as it is utilized for automation purposes by default.
AutomationID property can be set as per need. The most preferred method for this is to call System. GetCommandLineArgs at any random point in the application. It is the language used to instantiate. NET objects. Callback function returns bool value if true new value is valid else invalid value. As the name tells it is a way to customize or personalize the look or appearance of objects.
A style is a collection of values which represents properties of a specified control. We can assign certain set of styles collectively for a specific type of control like all buttons, all textboxes etc or restrict the style to be used only by those controls which you want explicitly with the help of keys x: Dependency properties are the type of properties which belong to a specific class but can be used for another class.
What is the difference between Silverlight and WPF browser application? These are the main differences between the Silverlight and WPF browser application:. NET framework is needed for running WPF browser application on the client machine while Silverlight runs using only plug-in. The applications made in WPF depend on the operating system because. NET framework only runs on Windows. On the other hand, Silverlight plug-ins can be installed on those OS also, which are not Windows. Dot Net Training Online.
A list of most important features of MVVM:. It improves simplicity and testability. It is 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. Namespace can be defined as an environment or an abstract container used to hold a logical grouping of unique identifiers or symbols.
Page controls Window controls 1. Page controls preside over the hosted browsers applications. Window controls preside over windows application. Page controls cannot contain window control. Window controls may contain page control. One way of displaying data at run time and design time is to declare your data in XAML. With a d: The type converter is helpful to convert a string into the appropriate value type where there is no markup extension usage. Type Converter defines four members for converting to and from string for xaml purposes.
It has some important properties like IsSelected and IsHighlighted and also some necessary events like Selected and Unselected. ComboBoxItem is a content control and is thus very useful for adding simple strings to a ComboBox. Informatica Training Videos. WPF is a presentation language. Windows services need specific permissions to execute some GUI related functions.
Therefore, if it does not get the required permissions, it gives errors. They are a special kind of FrameworkElement that provide visual clues to the user. They are also used to add handles to elements and give information about the state of a control.
Adorners are bound to the UIElement and are rendered on a surface that lies above the element, which is adorned. This surface is called an AdornerLayer. Adorners are mostly placed relatively to the bounded element.
One of the major differences is that. But Silverlight runs using only the plug-in. 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. A Value Converter is known to function as a bridge between a source and a target that is necessary when a target is bound with one source, for example, if you have a text box then you also has a button control.
You want to disable or enable or disable the button control when the text of the text box is null or filled. Sometimes the string data needs to be converted into Boolean. This is only possible when using a Value Converter. Data namespace and then implement the two methods Convert Back and Convert.
The bound object that emits the data is called the Source, and the other that accepts the data is called the Target. It is a framework that can be used to build Silverlight apps and WPF. It has been designed to build solid applications in Silverlight and WPF that normally have a single code base.
It is helpful in developing a client application, which is in a modular fashion. It is done so to divide large, complex applications into simple modules. It is used to put text on the screen, very much like using the Label control, but in a much less resource demanding and simpler way. Both the TextBlock and Label, offer their unique advantages, so the situation demands what you may use at one particular time.
It helps to develop the client application in a modular fashion so that complexity of a large application can be divided into simpler modules. This is a class file that calls Shell Shell.
XAML and so creates catalogue of module. This is like a Master Page having regions. It is like placeholders to register views.
Each module can have one or more View s which are registered to Region in the Shell through Region Manager. In the MVP pattern the User sends the input to the view, the view forward it to presenter and presenter then modify the view or the model depending on the type of user action. The view and the presenter are tightly coupled through bi-directional relationship.
The model does not know about the presenter. In this pattern there is only one controller that gets all the inputs directly, it modifies the data in the model depending upon the type of the input. Both the model and the view are created by the controller. The view only knows about the model, but the model does not know about any other objects. It is based on the Model-view-controller pattern MVC , MVVM is a way of creating client applications that leverages core features of the WPF platform, allows for simple unit testing of application functionality, and helps developers and designers work together with less technical difficulties.
What is the difference between Static and Dynamic resources? The most basic difference is that StaticResource evaluates the resource one time only, but DynamicResource evaluates it every time the resource is required. And due to this reason, DyanamicResource is heavy on the system but it makes pages or windows load faster. A Static Resource will be resolved and assigned to the property during the loading of the XAML that occurs before the application is actually run.
It will only be assigned once and any changes to the resource dictionary is ignored. Static resource references work best for the following circumstances:. Your application design concentrates most of its resources into page or application level resource dictionaries. Static resource references are not re-evaluated based on runtime behaviours such as reloading a page, and therefore there can be some performance benefit to avoiding large numbers of dynamic resource references when they are not necessary per your resource and application design.
You are setting the value of a property that is not on a Dependency Object or a freezable. You are creating a resource dictionary that will be compiled into a DLL, and packaged as part of the application or shared between applications. Dynamic Resources. A Dynamic Resource assigns an Expression object to the property during loading but does not actually lookup the resource until runtime when the Expression object is asked for the value.
This defers looking up the resource until it is needed at runtime. The value of the resource depends on conditions that are not known until runtime. This includes system resources, or resources that are otherwise user settable. For example, you can create setter values that refer to system properties, as exposed by System Colours, System Fonts, or System Parameters. These values are truly dynamic because they ultimately come from the runtime environment of the user and operating system.
You might also have application-level themes that can change, where page-level resource access must also capture the change. You are creating or referencing theme styles for a custom control. Converter are used in Data Binding. Templates in WPF Question What are the various layout panels in WPF? WPF comes with the following five built-in panels: Each panel has a different way to position and reposition child controls placed within that panel. The following articles in this series will summarise these panels and their usages.
Similar to any other WPF control, a Panel control may be represented in two ways. Panels Question Attached properties are basically Dependency Properties that allows the attachment of a value to any random object. 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. IsMatch txt. In my MainWindow.
What is resource in WPF?
How many types of resources in WPF? 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 is as follows: Resources in WPF Question What is the difference between Static and Dynamic resources? And due to this reason, DyanamicResource is heavy on the system but it makes pages or windows load faster.
It will only be assigned once and any changes to the resource dictionary is ignored. Static resource references work best for the following circumstances: Your application design concentrates most of its resources into page or application level resource dictionaries.
Static resource references are not re-evaluated based on runtime behaviours such as reloading a page, and therefore there can be some performance benefit to avoiding large numbers of dynamic resource references when they are not necessary per your resource and application design. You are setting the value of a property that is not on a Dependency Object or a freezable. You are creating a resource dictionary that will be compiled into a DLL, and packaged as part of the application or shared between applications.
This defers looking up the resource until it is needed at runtime. Dynamic resources work best for the following circumstances: The value of the resource depends on conditions that are not known until runtime. This includes system resources, or resources that are otherwise user settable. For example, you can create setter values that refer to system properties, as exposed by System Colours, System Fonts, or System Parameters.
These values are truly dynamic because they ultimately come from the runtime environment of the user and operating system. You might also have application-level themes that can change, where page-level resource access must also capture the change. You are creating or referencing theme styles for a custom control. You intend to adjust the contents of a Resource Dictionary during an application lifetime.
A Dependency Property is a property whose value depends on the external sources, such as animation, data binding, styles, or visual tree inheritance.
Not only this, but a Dependency Property also has the builtin feature of providing notification when the property has changed, data binding and styling. Advantages of a Dependency Property: Show dpSample. What is Attached Properties and how to register it? Attached Properties AP 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.
One of the misconceptions that a WPF developer usually has is that these properties can only be defined in the parent control the control in which we want to use them. AP can be defined in one of the following three contexts: What is a Routed event? Routed Events is about the Hierarchy of the controls you are using in the Events.
Routed Events are a new Infrastructure given by WPF that permit events to tunnel down the tree to the target elements or Bubble up to the Root element.
Routed Events are just like normal events. Tunneling events are the reverse of the Bubbling events. Tunneling Events raised first in the controls hierarchy. These events are raised by the Root elements. This allows events to tunnel down the tree.
Bubbling Events: Bubbling Events are those Events which are first raised by the control than raised by the other controls in the control hierarchy. It allows Bubble up to the tree till the Root Element. First Tunneling events are raised then bubbling events raised.
Direct Event: Direct Event is generally raised by the control itself. The behavior of this event is same as the. NET general event. What is Rotate transform in WPF?
RotateTransform rotates an element clockwise by a specified angle about the point. The Angle property represents the angle in degrees to rotate clockwise. By default, a ScaleTransform is centered at the point 0,0 , which corresponds to the upper-left corner of the rectangle. Creates two rectangles with same position and sizes accept the second rectangle is rotated at 45 degrees.
The ControlTemplate contains the tree of elements that define the desired look. We can create a borderless window in two ways. Extensible Application Markup Language and pronounced "zammel" is a markup language used to instantiate.
NET objects. Although XAML is a technology that can be applied to many different problem domains, its primary role in life is to construct WPF user interfaces. Attaching event handler in the most cases, for example Click on Button is easy to do in Visual Studio. However once we understand how events are wired up in XAML,we'll be able create more sophisticated connections. Defining resources: Resources are the object which once we define in XAML can be re-used in the various places inside markup.
Resources allow us to centralize and standardize formatting, and create nonvisual objects such as templates and animations.
Defining control template: WPF controls are designed to be lookless, which means we can substitute our custom visuals in place of the standard appearance. To do so, we must create our own control template, which is nothing more than a block of XAML markup. Encompasses the elements that describe WPF content, such as vector graphics, controls, and documents. Silverlight XAML: Silverlight is a cross-platform browser plug-in that allows us to create rich web content.
Encompasses the elements that describe Windows Workflow Foundation. How to set content of a NavigationWindow? The Navigation Window class is derived from the Window class, so it inherits all the properties of Windows such as methods, properties and events.
The navigation window provides backward and forward buttons for navigating to pages that we have visited before or have yet to visit. Creating Navigation Paged Application: To create Navigation Window based applications, use a Navigation Window container instead of a Window container as shown in the following picture and the source is the property of the Navigation window and write the name of the page that you want to set as the home page as shown in the following picture: A ChildWindow control is a light weight window that can be used as a child window or a popup control.
The parent window is automatically disabled when a child window is active and modal. You can think of a ChildWindow as a custom modal or modeless dialog where you can place any child controls you want. However, the ChildWindow has several common Window properties.
Creating a ChildWindow: The ChildWindow control is defined in the System. Controls namespace. Content Controls are mainly parent containers to hold the content. It displays information to the user to be viewed but that generally won't be modified. With content controls, the following aspects: A Property specifies the object's appearance or behavior.
For example, the IsEnabled property specifies whether the user can interact with a control or not. A Method is a routine that a control executes to perform something. For example Coa unt Method counts the number of items available for the object or control. An event is related when a control raises one to let your application know that something has happened.
For example TextBox raises a TextChanged event whenever its text changes. 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: How can I clip or crop an image?
Clipping a region is a process of displaying partial area of a region by setting the outline of a region. What are Converters in WPF? Converters provide substantial supremacy since they allow insertion of an object between a source and a target object.
At a high level, converters are a chunk of custom code hooked up using the binding and the data will flow via that converter. So, whenever data is flown from a source to a target, one can change the value or can change the type of object that needs to be set on the target property.
So, whenever data travels from source to target, it can be transformed in two ways: Data value: Here the transformation will be done with just the value by keeping the data type intact.
For example, for number fields, you can transform a value from a floating point number to an integer by keeping the actual value as a float. Data type: One can also transform the data type. For example, setting a style based on some Boolean flag. This interface has the following two methods: Is called when data is flowing from a source to a target.
Is called when data is flowing from a target to a source. It is basically useful in two-way binding scenarios. Converters in WPF Question 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. Value update will be on hold until the focus moves out of the control.
Value update will happen whenever a target property changes. It usually happen on every keystoke. Used to defer source updates until the user does it forcibly by the click of a button or so. For DataGrid: Lost Focus: Cell lost focus Default: What are various ways of doing alignment in WPF? The FrameworkElement has two alignment properties: HorizontalAlignment and Vertical Alignment.
The Horizontal Alignment property is a type of HorizontalAlignment enumeration and represents how a child element is positioned within a parent element horizontally. The Left, Center and Right properties sets a child element to left, center and right of the parent element.
The Stretch property stretches a child element to fill the parent element's allocated layout space. The Top, Center and Bottom properties set a child element to top, center or bottom of the parent element. The Stretch property stretches a child element to fill the parent element's allocated layout space vertically. Horizontal and Vertical Alignment Question A ToolTip control shows some information or a hint about a control in a floating box when the mouse hovers over that control and it disappears when the mouse is moved away from that control.
Tool tips are used to help the users to learn the purpose of Controls in many Windows-based programs. Tooltips are nothing but small rectangles that appear when the user hovers the mouse pointer over the Control.
The rectangle contains a short piece of text describing the control. Once displayed, the tips disappear when the user moves the mouse pointer away from the linked control or clicks a mouse button, or after a short delay. ToolTip Example: Drag a Button control from the toolbox and drop it. Add a ToolTip property to the button with a message you want to show on mouse hover of the button.
We can add a ToolTip in two ways. First the button shows the simplest way to display a ToolTip. The second method is preferred for creating a customized ToolTip. How can ListBox be made to scroll smoothly?
A ListBox control is an items control that works as a ListBox control but only one item from the collection is visible at a time and clicking on the ListBox makes the collection visible and allows users to pick an item from the collection.